diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 741606732144..2e4913dca478 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -450,6 +450,7 @@ in vaultwarden = handleTest ./vaultwarden.nix {}; vector = handleTest ./vector.nix {}; victoriametrics = handleTest ./victoriametrics.nix {}; + vikunja = handleTest ./vikunja.nix {}; virtualbox = handleTestOn ["x86_64-linux"] ./virtualbox.nix {}; vscodium = handleTest ./vscodium.nix {}; wasabibackend = handleTest ./wasabibackend.nix {}; diff --git a/nixos/tests/vikunja.nix b/nixos/tests/vikunja.nix new file mode 100644 index 000000000000..bd884b37f4f9 --- /dev/null +++ b/nixos/tests/vikunja.nix @@ -0,0 +1,65 @@ +import ./make-test-python.nix ({ pkgs, lib, ... }: { + name = "vikunja"; + + meta = with lib.maintainers; { + maintainers = [ em0lar ]; + }; + + nodes = { + vikunjaSqlite = { ... }: { + services.vikunja = { + enable = true; + database = { + type = "sqlite"; + }; + frontendScheme = "http"; + frontendHostname = "localhost"; + }; + services.nginx.enable = true; + }; + vikunjaPostgresql = { pkgs, ... }: { + services.vikunja = { + enable = true; + database = { + type = "postgres"; + user = "vikunja-api"; + database = "vikunja-api"; + host = "/run/postgresql"; + }; + frontendScheme = "http"; + frontendHostname = "localhost"; + }; + services.postgresql = { + enable = true; + ensureDatabases = [ "vikunja-api" ]; + ensureUsers = [ + { name = "vikunja-api"; + ensurePermissions = { "DATABASE \"vikunja-api\"" = "ALL PRIVILEGES"; }; + } + ]; + }; + services.nginx.enable = true; + }; + }; + + testScript = + '' + vikunjaSqlite.wait_for_unit("vikunja-api.service") + vikunjaSqlite.wait_for_open_port(3456) + vikunjaSqlite.succeed("curl --fail http://localhost:3456/api/v1/info") + + vikunjaSqlite.wait_for_unit("nginx.service") + vikunjaSqlite.wait_for_open_port(80) + vikunjaSqlite.succeed("curl --fail http://localhost/api/v1/info") + vikunjaSqlite.succeed("curl --fail http://localhost") + + vikunjaPostgresql.wait_for_unit("vikunja-api.service") + vikunjaPostgresql.wait_for_open_port(3456) + vikunjaPostgresql.succeed("curl --fail http://localhost:3456/api/v1/info") + + vikunjaPostgresql.wait_for_unit("nginx.service") + vikunjaPostgresql.wait_for_open_port(80) + vikunjaPostgresql.succeed("curl --fail http://localhost/api/v1/info") + vikunjaPostgresql.succeed("curl --fail http://localhost") + ''; +}) diff --git a/pkgs/servers/web-apps/vikunja/api.nix b/pkgs/servers/web-apps/vikunja/api.nix index 4cc9d634b3c2..285352da36e6 100644 --- a/pkgs/servers/web-apps/vikunja/api.nix +++ b/pkgs/servers/web-apps/vikunja/api.nix @@ -1,4 +1,4 @@ -{ lib, buildGoModule, fetchFromGitea, mage, writeShellScriptBin }: +{ lib, buildGoModule, fetchFromGitea, mage, writeShellScriptBin, nixosTests }: buildGoModule rec { pname = "vikunja-api"; @@ -45,6 +45,8 @@ buildGoModule rec { runHook postInstall ''; + passthru.tests.vikunja = nixosTests.vikunja; + meta = { description = "API of the Vikunja to-do list app"; homepage = "https://vikunja.io/"; diff --git a/pkgs/servers/web-apps/vikunja/frontend.nix b/pkgs/servers/web-apps/vikunja/frontend.nix index 0f90dba91575..e3b8a8785dec 100644 --- a/pkgs/servers/web-apps/vikunja/frontend.nix +++ b/pkgs/servers/web-apps/vikunja/frontend.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, fetchurl, unzip, ... }: +{ stdenv, lib, fetchurl, unzip, nixosTests, ... }: stdenv.mkDerivation rec { pname = "vikunja-frontend"; @@ -21,6 +21,8 @@ stdenv.mkDerivation rec { runHook postInstall ''; + passthru.tests.vikunja = nixosTests.vikunja; + meta = { description = "Frontend of the Vikunja to-do list app"; homepage = "https://vikunja.io/";