about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2021-07-19 04:56:08 +0300
committerVika <vika@fireburn.ru>2021-07-19 04:57:12 +0300
commit5476bb17dc428bcef8163c26c320e5c3ef1ff5d5 (patch)
tree61f57a64379dda47d8c6a6a97e1768b3e6f4538c
parentbf4f0eafe402d128a63695559134e6fe05d51a2e (diff)
Added a NixOS test for onboarding workflow
-rw-r--r--flake.nix29
1 files changed, 28 insertions, 1 deletions
diff --git a/flake.nix b/flake.nix
index b05e05c..3ff32f9 100644
--- a/flake.nix
+++ b/flake.nix
@@ -166,9 +166,36 @@
         };
 
         testScript = ''
+          import json
+
           kittybox.start()
           kittybox.wait_for_unit("default.target")
-          kittybox.succeed("curl --silent http://localhost:8080/micropub")
+          with subtest("Verify that Kittybox started correctly..."):
+              kittybox.succeed("curl --silent http://localhost:8080/micropub")
+
+          with subtest("Onboarding should correctly work..."):
+              onboarding_json = {
+                  "user": {
+                      "type": ["h-card"],
+                      "properties": {
+                          "name": ["Vika"],
+                          "pronoun": ["she/her"],
+                          "url": ["https://twitter.com/VikaNezrimaya"],
+                          "note": ["Just a simple girl. Do I even exist or am I a vestige of the past long gone?"]
+                      }
+                    },
+                    "first_post": {
+                        "type": ["h-entry"],
+                        "properties": {
+                            "content": ["Hello!"]
+                        }
+                    },
+                    "blog_name": "Test Hideout",
+                    "feeds": []
+              }
+              kittybox.succeed("echo '{}' | curl --silent http://localhost:8080/ -d@- -H 'Content-Type: application/json'".format(json.dumps(onboarding_json).replace("'", "'\''$")))
+              # Testing for a known string is the easiest way to determine that the onboarding worked
+              kittybox.succeed("curl --silent http://localhost:8080/ | grep 'vestige of the past long gone'")
         '';
       });
     };