From dc248a81fa64d002d6bcab8cd0b588aac422af3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20van=20Br=C3=BCgge?= Date: Tue, 8 Oct 2024 22:26:49 +0100 Subject: [PATCH] nixos/tests/linkwarden: init tests --- nixos/tests/all-tests.nix | 1 + nixos/tests/web-apps/linkwarden.nix | 30 ++++++++++++++++++++++++++ pkgs/by-name/li/linkwarden/package.nix | 5 +++++ 3 files changed, 36 insertions(+) create mode 100644 nixos/tests/web-apps/linkwarden.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index be077353de00cf..0a4a5015846225 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -547,6 +547,7 @@ in { lightdm = handleTest ./lightdm.nix {}; lighttpd = handleTest ./lighttpd.nix {}; limesurvey = handleTest ./limesurvey.nix {}; + linkwarden = handleTest ./web-apps/linkwarden.nix {}; listmonk = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./listmonk.nix {}; litestream = handleTest ./litestream.nix {}; lldap = handleTest ./lldap.nix {}; diff --git a/nixos/tests/web-apps/linkwarden.nix b/nixos/tests/web-apps/linkwarden.nix new file mode 100644 index 00000000000000..ec948b8871e482 --- /dev/null +++ b/nixos/tests/web-apps/linkwarden.nix @@ -0,0 +1,30 @@ +import ../make-test-python.nix ( + { ... }: + { + name = "linkwarden-nixos"; + + nodes.machine = + { pkgs, ... }: + let + secretsFile = pkgs.writeText "linkwarden-secret-env" '' + NEXTAUTH_SECRET=VERY_SENSITIVE_SECRET + ''; + in + { + services.linkwarden = { + enable = true; + enableRegistration = true; + secretsFile = toString secretsFile; + }; + }; + + testScript = '' + machine.wait_for_unit("linkwarden.service") + + machine.wait_for_open_port(3000) + machine.succeed("curl --fail -s http://localhost:3000/") + + machine.succeed("curl -L --fail -s --data '{\"name\":\"Admin\",\"username\":\"admin\",\"password\":\"adminadmin\"}' -H 'Content-Type: application/json' -X POST http://localhost:3000/api/v1/users") + ''; + } +) diff --git a/pkgs/by-name/li/linkwarden/package.nix b/pkgs/by-name/li/linkwarden/package.nix index 26e8c97f347d32..a1665709b1c594 100644 --- a/pkgs/by-name/li/linkwarden/package.nix +++ b/pkgs/by-name/li/linkwarden/package.nix @@ -5,6 +5,7 @@ fetchFromGitHub, fetchYarnDeps, makeWrapper, + nixosTests, yarnBuildHook, yarnConfigHook, # dependencies @@ -126,6 +127,10 @@ stdenvNoCC.mkDerivation rec { runHook postInstall ''; + passthru.tests = { + inherit (nixosTests) linkwarden; + }; + meta = { description = "Self-hosted collaborative bookmark manager to collect, organize, and preserve webpages, articles, and more..."; homepage = "https://linkwarden.app/";