From 5610a5f0bf1a9df02bd3d5b55e2cdebef2440360 Mon Sep 17 00:00:00 2001 From: Vika Date: Tue, 24 May 2022 17:18:30 +0300 Subject: 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 --- smoke-test.nix | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 smoke-test.nix (limited to 'smoke-test.nix') 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'") +''; +} -- cgit 1.4.1