From 99d14360785dd1f04db7bbc79c195277895c4908 Mon Sep 17 00:00:00 2001 From: RatCornu Date: Mon, 10 Mar 2025 15:06:36 +0100 Subject: [PATCH] nixos/szurubooru: add nixos test --- nixos/tests/all-tests.nix | 1 + nixos/tests/szurubooru.nix | 52 +++++++++++++++++++++ pkgs/servers/web-apps/szurubooru/server.nix | 3 ++ 3 files changed, 56 insertions(+) create mode 100644 nixos/tests/szurubooru.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 6cb04827cb77..6bfdee9c3619 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1372,6 +1372,7 @@ in systemd-homed = runTest ./systemd-homed.nix; systemtap = handleTest ./systemtap.nix { }; startx = import ./startx.nix { inherit pkgs runTest; }; + szurubooru = handleTest ./szurubooru.nix { }; taler = handleTest ./taler { }; tandoor-recipes = runTest ./tandoor-recipes.nix; tandoor-recipes-script-name = runTest ./tandoor-recipes-script-name.nix; diff --git a/nixos/tests/szurubooru.nix b/nixos/tests/szurubooru.nix new file mode 100644 index 000000000000..adcfecdbf34b --- /dev/null +++ b/nixos/tests/szurubooru.nix @@ -0,0 +1,52 @@ +import ./make-test-python.nix ( + { lib, pkgs, ... }: + { + name = "szurubooru"; + meta.maintainers = with lib.maintainers; [ ratcornu ]; + + nodes.machine = + let + dbpass = "changeme"; + in + + { config, ... }: + { + services.postgresql = { + enable = true; + initialScript = pkgs.writeText "init.sql" '' + CREATE USER ${config.services.szurubooru.database.user} WITH PASSWORD '${dbpass}'; + CREATE DATABASE ${config.services.szurubooru.database.name} WITH OWNER ${config.services.szurubooru.database.user}; + ''; + }; + + services.szurubooru = { + enable = true; + + dataDir = "/var/lib/szurubooru"; + + server = { + port = 6666; + settings = { + domain = "http://127.0.0.1"; + secretFile = pkgs.writeText "secret" "secret"; + debug = 1; + }; + }; + + database = { + host = "localhost"; + port = 5432; + name = "szurubooru"; + user = "szurubooru"; + passwordFile = pkgs.writeText "pass" "${dbpass}"; + }; + }; + }; + + testScript = '' + machine.wait_for_unit("szurubooru.service") + machine.wait_for_open_port(6666) + machine.succeed('curl -H "Content-Type: application/json" -H "Accept: application/json" --fail http://127.0.0.1:6666/info') + ''; + } +) diff --git a/pkgs/servers/web-apps/szurubooru/server.nix b/pkgs/servers/web-apps/szurubooru/server.nix index a85b749c7426..0d5a7b65e257 100644 --- a/pkgs/servers/web-apps/szurubooru/server.nix +++ b/pkgs/servers/web-apps/szurubooru/server.nix @@ -2,6 +2,7 @@ src, version, lib, + nixosTests, fetchPypi, python3, }: @@ -73,6 +74,8 @@ python.pkgs.buildPythonApplication { install -m0755 $src/szuru-admin $out/bin/szuru-admin ''; + passthru.tests.szurubooru = nixosTests.szurubooru; + meta = with lib; { description = "Server of szurubooru, an image board engine for small and medium communities"; homepage = "https://github.com/rr-/szurubooru";