about summary refs log tree commit diff
path: root/nixos/tests/shiori.nix
diff options
context:
space:
mode:
authorDanilo Reyes <CaptainJawZ@protonmail.com>2024-04-26 20:16:54 -0600
committerDanilo Reyes <CaptainJawZ@protonmail.com>2024-06-29 15:30:22 -0600
commit4f021e14a31eded4a7e3076ba7f71b4f0f3d46cb (patch)
treeb5546b548313b455204ffd04ed829edbc4c11157 /nixos/tests/shiori.nix
parent01670753c486e654ab460465a6f072cfebc39584 (diff)
shiori: 1.5.5 -> 1.7.0
Diffstat (limited to 'nixos/tests/shiori.nix')
-rw-r--r--nixos/tests/shiori.nix133
1 files changed, 66 insertions, 67 deletions
diff --git a/nixos/tests/shiori.nix b/nixos/tests/shiori.nix
index d0f68b903f8c3..99c1301cc3f8f 100644
--- a/nixos/tests/shiori.nix
+++ b/nixos/tests/shiori.nix
@@ -1,80 +1,79 @@
-import ./make-test-python.nix ({ pkgs, lib, ...}:
+import ./make-test-python.nix ({ pkgs, lib, ... }:
 
-{
-  name = "shiori";
-  meta.maintainers = with lib.maintainers; [ minijackson ];
+  {
+    name = "shiori";
+    meta.maintainers = with lib.maintainers; [ minijackson ];
 
-  nodes.machine =
-    { ... }:
-    { services.shiori.enable = true; };
+    nodes.machine = { ... }: { services.shiori.enable = true; };
 
-  testScript = let
-    authJSON = pkgs.writeText "auth.json" (builtins.toJSON {
-      username = "shiori";
-      password = "gopher";
-      owner = true;
-    });
+    testScript = let
+      authJSON = pkgs.writeText "auth.json" (builtins.toJSON {
+        username = "shiori";
+        password = "gopher";
+        owner = true;
+      });
 
-  insertBookmark = {
-    url = "http://example.org";
-    title = "Example Bookmark";
-  };
+      insertBookmark = {
+        url = "http://example.org";
+        title = "Example Bookmark";
+      };
 
-  insertBookmarkJSON = pkgs.writeText "insertBookmark.json" (builtins.toJSON insertBookmark);
-  in ''
-    import json
+      insertBookmarkJSON =
+        pkgs.writeText "insertBookmark.json" (builtins.toJSON insertBookmark);
+    in ''
+      import json
 
-    machine.wait_for_unit("shiori.service")
-    machine.wait_for_open_port(8080)
-    machine.succeed("curl --fail http://localhost:8080/")
-    machine.succeed("curl --fail --location http://localhost:8080/ | grep -i shiori")
+      machine.wait_for_unit("shiori.service")
+      machine.wait_for_open_port(8080)
+      machine.succeed("curl --fail http://localhost:8080/")
+      machine.succeed("curl --fail --location http://localhost:8080/ | grep -i shiori")
 
-    with subtest("login"):
-        auth_json = machine.succeed(
-            "curl --fail --location http://localhost:8080/api/login "
-            "-X POST -H 'Content-Type:application/json' -d @${authJSON}"
-        )
-        auth_ret = json.loads(auth_json)
-        session_id = auth_ret["session"]
+      with subtest("login"):
+          auth_json = machine.succeed(
+              "curl --fail --location http://localhost:8080/api/login "
+              "-X POST -H 'Content-Type:application/json' -d @${authJSON}"
+          )
+          auth_ret = json.loads(auth_json)
+          session_id = auth_ret["session"]
 
-    with subtest("bookmarks"):
-        with subtest("first use no bookmarks"):
-            bookmarks_json = machine.succeed(
-                (
-                    "curl --fail --location http://localhost:8080/api/bookmarks "
-                    "-H 'X-Session-Id:{}'"
-                ).format(session_id)
-            )
+      with subtest("bookmarks"):
+          with subtest("first use no bookmarks"):
+              bookmarks_json = machine.succeed(
+                  (
+                      "curl --fail --location http://localhost:8080/api/bookmarks "
+                      "-H 'X-Session-Id:{}'"
+                  ).format(session_id)
+              )
 
-            if json.loads(bookmarks_json)["bookmarks"] != []:
-                raise Exception("Shiori have a bookmark on first use")
+              if json.loads(bookmarks_json)["bookmarks"] != []:
+                  raise Exception("Shiori have a bookmark on first use")
 
-        with subtest("insert bookmark"):
-            machine.succeed(
-                (
-                    "curl --fail --location http://localhost:8080/api/bookmarks "
-                    "-X POST -H 'X-Session-Id:{}' "
-                    "-H 'Content-Type:application/json' -d @${insertBookmarkJSON}"
-                ).format(session_id)
-            )
+          with subtest("insert bookmark"):
+              machine.succeed(
+                  (
+                      "curl --fail --location http://localhost:8080/api/bookmarks "
+                      "-X POST -H 'X-Session-Id:{}' "
+                      "-H 'Content-Type:application/json' -d @${insertBookmarkJSON}"
+                  ).format(session_id)
+              )
 
-        with subtest("get inserted bookmark"):
-            bookmarks_json = machine.succeed(
-                (
-                    "curl --fail --location http://localhost:8080/api/bookmarks "
-                    "-H 'X-Session-Id:{}'"
-                ).format(session_id)
-            )
+          with subtest("get inserted bookmark"):
+              bookmarks_json = machine.succeed(
+                  (
+                      "curl --fail --location http://localhost:8080/api/bookmarks "
+                      "-H 'X-Session-Id:{}'"
+                  ).format(session_id)
+              )
 
-            bookmarks = json.loads(bookmarks_json)["bookmarks"]
-            if len(bookmarks) != 1:
-                raise Exception("Shiori didn't save the bookmark")
+              bookmarks = json.loads(bookmarks_json)["bookmarks"]
+              if len(bookmarks) != 1:
+                  raise Exception("Shiori didn't save the bookmark")
 
-            bookmark = bookmarks[0]
-            if (
-                bookmark["url"] != "${insertBookmark.url}"
-                or bookmark["title"] != "${insertBookmark.title}"
-            ):
-                raise Exception("Inserted bookmark doesn't have same URL or title")
-  '';
-})
+              bookmark = bookmarks[0]
+              if (
+                  bookmark["url"] != "${insertBookmark.url}"
+                  or bookmark["title"] != "${insertBookmark.title}"
+              ):
+                  raise Exception("Inserted bookmark doesn't have same URL or title")
+    '';
+  })