···
-
import ./make-test-python.nix (
-
meta = with pkgs.lib.maintainers; {
-
maintainers = [ ma27 ];
-
virtualisation.memorySize = 2047;
-
settings.db.host = "/run/postgresql";
-
settings.db.user = "wiki-js";
-
settings.db.db = "wiki-js";
-
settings.logLevel = "debug";
-
services.postgresql = {
-
ensureDatabases = [ "wiki-js" ];
-
ensureDBOwnership = true;
-
systemd.services.wiki-js = {
-
requires = [ "postgresql.service" ];
-
after = [ "postgresql.service" ];
-
environment.systemPackages = with pkgs; [ jq ];
-
payloads.finalize = pkgs.writeText "finalize.json" (
-
adminEmail = "webmaster@example.com";
-
adminPassword = "notapassword";
-
adminPasswordConfirm = "notapassword";
-
siteUrl = "http://localhost:3000";
-
payloads.login = pkgs.writeText "login.json" (
-
mutation ($username: String!, $password: String!, $strategy: String!) {
-
login(username: $username, password: $password, strategy: $strategy) {
-
password = "notapassword";
-
username = "webmaster@example.com";
-
payloads.content = pkgs.writeText "content.json" (
-
mutation ($content: String!, $description: String!, $editor: String!, $isPrivate: Boolean!, $isPublished: Boolean!, $locale: String!, $path: String!, $publishEndDate: Date, $publishStartDate: Date, $scriptCss: String, $scriptJs: String, $tags: [String]!, $title: String!) {
-
create(content: $content, description: $description, editor: $editor, isPrivate: $isPrivate, isPublished: $isPublished, locale: $locale, path: $path, publishEndDate: $publishEndDate, publishStartDate: $publishStartDate, scriptCss: $scriptCss, scriptJs: $scriptJs, tags: $tags, title: $title) {
-
content = "# Header\n\nHello world!";
-
machine.wait_for_unit("multi-user.target")
-
machine.wait_for_open_port(3000)
-
machine.succeed("curl -sSf localhost:3000")
-
result = machine.succeed(
-
"curl -sSf localhost:3000/finalize -X POST -d "
-
+ "@${payloads.finalize} -H 'Content-Type: application/json' "
-
+ "| jq .ok | xargs echo"
-
assert result.strip() == "true", f"Expected true, got {result}"
-
# During the setup the service gets restarted, so we use this
-
# to check if the setup is done.
-
machine.wait_until_fails("curl -sSf localhost:3000")
-
machine.wait_until_succeeds("curl -sSf localhost:3000")
-
with subtest("Base functionality"):
-
auth = machine.succeed(
-
"curl -sSf localhost:3000/graphql -X POST "
-
+ "-d @${payloads.login} -H 'Content-Type: application/json' "
-
+ "| jq '.[0].data.authentication.login.jwt' | xargs echo"
-
create = machine.succeed(
-
"curl -sSf localhost:3000/graphql -X POST "
-
+ "-d @${payloads.content} -H 'Content-Type: application/json' "
-
+ f"-H 'Authorization: Bearer {auth}' "
-
+ "| jq '.[0].data.pages.create.responseResult.succeeded'|xargs echo"
-
assert create.strip() == "true", f"Expected true, got {create}"
···
+
meta = with pkgs.lib.maintainers; {
+
maintainers = [ ma27 ];
+
virtualisation.memorySize = 2047;
+
settings.db.host = "/run/postgresql";
+
settings.db.user = "wiki-js";
+
settings.db.db = "wiki-js";
+
settings.logLevel = "debug";
+
services.postgresql = {
+
ensureDatabases = [ "wiki-js" ];
+
ensureDBOwnership = true;
+
systemd.services.wiki-js = {
+
requires = [ "postgresql.service" ];
+
after = [ "postgresql.service" ];
+
environment.systemPackages = with pkgs; [ jq ];
+
payloads.finalize = pkgs.writeText "finalize.json" (
+
adminEmail = "webmaster@example.com";
+
adminPassword = "notapassword";
+
adminPasswordConfirm = "notapassword";
+
siteUrl = "http://localhost:3000";
+
payloads.login = pkgs.writeText "login.json" (
+
mutation ($username: String!, $password: String!, $strategy: String!) {
+
login(username: $username, password: $password, strategy: $strategy) {
+
password = "notapassword";
+
username = "webmaster@example.com";
+
payloads.content = pkgs.writeText "content.json" (
+
mutation ($content: String!, $description: String!, $editor: String!, $isPrivate: Boolean!, $isPublished: Boolean!, $locale: String!, $path: String!, $publishEndDate: Date, $publishStartDate: Date, $scriptCss: String, $scriptJs: String, $tags: [String]!, $title: String!) {
+
create(content: $content, description: $description, editor: $editor, isPrivate: $isPrivate, isPublished: $isPublished, locale: $locale, path: $path, publishEndDate: $publishEndDate, publishStartDate: $publishStartDate, scriptCss: $scriptCss, scriptJs: $scriptJs, tags: $tags, title: $title) {
+
content = "# Header\n\nHello world!";
+
machine.wait_for_unit("multi-user.target")
+
machine.wait_for_open_port(3000)
+
machine.succeed("curl -sSf localhost:3000")
+
result = machine.succeed(
+
"curl -sSf localhost:3000/finalize -X POST -d "
+
+ "@${payloads.finalize} -H 'Content-Type: application/json' "
+
+ "| jq .ok | xargs echo"
+
assert result.strip() == "true", f"Expected true, got {result}"
+
# During the setup the service gets restarted, so we use this
+
# to check if the setup is done.
+
machine.wait_until_fails("curl -sSf localhost:3000")
+
machine.wait_until_succeeds("curl -sSf localhost:3000")
+
with subtest("Base functionality"):
+
auth = machine.succeed(
+
"curl -sSf localhost:3000/graphql -X POST "
+
+ "-d @${payloads.login} -H 'Content-Type: application/json' "
+
+ "| jq '.[0].data.authentication.login.jwt' | xargs echo"
+
create = machine.succeed(
+
"curl -sSf localhost:3000/graphql -X POST "
+
+ "-d @${payloads.content} -H 'Content-Type: application/json' "
+
+ f"-H 'Authorization: Bearer {auth}' "
+
+ "| jq '.[0].data.pages.create.responseResult.succeeded'|xargs echo"
+
assert create.strip() == "true", f"Expected true, got {create}"