about summary refs log tree commit diff
path: root/smoke-test.nix
diff options
context:
space:
mode:
authorVika <vika@fireburn.ru>2022-05-24 17:18:30 +0300
committerVika <vika@fireburn.ru>2022-05-24 17:18:30 +0300
commit5610a5f0bf1a9df02bd3d5b55e2cdebef2440360 (patch)
tree8394bcf1dcc204043d7adeb8dde2e2746977606e /smoke-test.nix
parent2f93873122b47e42f7ee1c38f1f04d052a63599c (diff)
flake.nix: reorganize
 - Kittybox's source code is moved to a subfolder
   - This improves build caching by Nix since it doesn't take changes
     to other files into account
 - Package and test definitions were spun into separate files
   - This makes my flake.nix much easier to navigate
   - This also makes it somewhat possible to use without flakes (but
     it is still not easy, so use flakes!)
 - Some attributes were moved in compliance with Nix 2.8's changes to
   flake schema
Diffstat (limited to 'smoke-test.nix')
-rw-r--r--smoke-test.nix36
1 files changed, 36 insertions, 0 deletions
diff --git a/smoke-test.nix b/smoke-test.nix
new file mode 100644
index 0000000..fbbc8a7
--- /dev/null
+++ b/smoke-test.nix
@@ -0,0 +1,36 @@
+kittybox:
+{ lib, ... }: {
+  name = "nixos-kittybox";
+
+  nodes = {
+    kittybox = { config, pkgs, lib, ... }: {
+      imports = [ kittybox.nixosModules.default ];
+
+      services.kittybox = {
+        enable = true;
+        # It never actually contacts those endpoints anyway unless we use Micropub so it's fine!
+        # TODO: Once we have self-hosted software for those endpoints,
+        #       make an e2e test for common workflows (e.g. making a post)
+        tokenEndpoint = "https://example.com";
+        authorizationEndpoint = "https://example.com";
+        logLevel = "info,kittybox=debug,retainer::cache=warn,h2=warn,rustls=warn";
+      };
+
+      environment.systemPackages = with pkgs; [
+        curl
+      ];
+    };
+  };
+
+  testScript = ''
+    with subtest("Verify that Kittybox started correctly..."):
+        kittybox.wait_for_open_port(8080)
+        kittybox.succeed("curl --silent http://localhost:8080/micropub")
+
+    with subtest("Onboarding should correctly work..."):
+        kittybox.copy_from_host("${./onboarding.json}", "/root/onboarding.json")
+        kittybox.succeed("curl -vvv http://localhost:8080/onboarding -d@/root/onboarding.json -H 'Content-Type: application/json'")
+        # 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'")
+'';
+}