summary refs log tree commit diff
path: root/nixos/tests/gotify-server.nix
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2019-11-24 13:21:16 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2019-11-24 13:49:04 +0100
commit2403c1a88d9ce295fe8f89ba908f304939eb3091 (patch)
tree7417b40d71ca78a660d4a556b7e2ee9bbe31bb41 /nixos/tests/gotify-server.nix
parent7c23496e46303f1315ca94316b7447891d81de44 (diff)
downloadnixpkgs-2403c1a88d9ce295fe8f89ba908f304939eb3091.tar
nixpkgs-2403c1a88d9ce295fe8f89ba908f304939eb3091.tar.gz
nixpkgs-2403c1a88d9ce295fe8f89ba908f304939eb3091.tar.bz2
nixpkgs-2403c1a88d9ce295fe8f89ba908f304939eb3091.tar.lz
nixpkgs-2403c1a88d9ce295fe8f89ba908f304939eb3091.tar.xz
nixpkgs-2403c1a88d9ce295fe8f89ba908f304939eb3091.tar.zst
nixpkgs-2403c1a88d9ce295fe8f89ba908f304939eb3091.zip
nixos/gotify-server: port test to python test-driver
Diffstat (limited to 'nixos/tests/gotify-server.nix')
-rw-r--r--nixos/tests/gotify-server.nix44
1 files changed, 22 insertions, 22 deletions
diff --git a/nixos/tests/gotify-server.nix b/nixos/tests/gotify-server.nix
index 0ffc3138d5a..c6e00686aed 100644
--- a/nixos/tests/gotify-server.nix
+++ b/nixos/tests/gotify-server.nix
@@ -1,4 +1,4 @@
-import ./make-test.nix ({ pkgs, lib, ...} : {
+import ./make-test-python.nix ({ pkgs, lib, ...} : {
   name = "gotify-server";
   meta = with pkgs.stdenv.lib.maintainers; {
     maintainers = [ ma27 ];
@@ -14,32 +14,32 @@ import ./make-test.nix ({ pkgs, lib, ...} : {
   };
 
   testScript = ''
-    startAll;
+    machine.start()
 
-    $machine->waitForUnit("gotify-server");
-    $machine->waitForOpenPort(3000);
+    machine.wait_for_unit("gotify-server.service")
+    machine.wait_for_open_port(3000)
 
-    my $token = $machine->succeed(
-      "curl --fail -sS -X POST localhost:3000/application -F name=nixos " .
-      '-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" ' .
-      '| jq .token | xargs echo -n'
-    );
+    token = machine.succeed(
+        "curl --fail -sS -X POST localhost:3000/application -F name=nixos "
+        + '-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" '
+        + "| jq .token | xargs echo -n"
+    )
 
-    my $usertoken = $machine->succeed(
-      "curl --fail -sS -X POST localhost:3000/client -F name=nixos " .
-      '-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" ' .
-      '| jq .token | xargs echo -n'
-    );
+    usertoken = machine.succeed(
+        "curl --fail -sS -X POST localhost:3000/client -F name=nixos "
+        + '-H "Authorization: Basic $(echo -ne "admin:admin" | base64 --wrap 0)" '
+        + "| jq .token | xargs echo -n"
+    )
 
-    $machine->succeed(
-      "curl --fail -sS -X POST 'localhost:3000/message?token=$token' -H 'Accept: application/json' " .
-      '-F title=Gotify -F message=Works'
-    );
+    machine.succeed(
+        f"curl --fail -sS -X POST 'localhost:3000/message?token={token}' -H 'Accept: application/json' "
+        + "-F title=Gotify -F message=Works"
+    )
 
-    my $title = $machine->succeed(
-      "curl --fail -sS 'localhost:3000/message?since=0&token=$usertoken' | jq '.messages|.[0]|.title' | xargs echo -n"
-    );
+    title = machine.succeed(
+        f"curl --fail -sS 'localhost:3000/message?since=0&token={usertoken}' | jq '.messages|.[0]|.title' | xargs echo -n"
+    )
 
-    $title eq "Gotify" or die "Wrong title ($title), expected 'Gotify'!";
+    assert title == "Gotify"
   '';
 })