From fca068a55862456224bedee8ff2f780b0028c6f8 Mon Sep 17 00:00:00 2001 From: Victor Freire Date: Wed, 24 May 2023 09:48:02 -0300 Subject: [PATCH] nixos/tests/legit: init --- nixos/tests/all-tests.nix | 1 + nixos/tests/legit.nix | 54 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 nixos/tests/legit.nix diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 49a7db012a17..abe281a204b4 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -278,6 +278,7 @@ in { fsck = handleTest ./fsck.nix {}; fsck-systemd-stage-1 = handleTest ./fsck.nix { systemdStage1 = true; }; ft2-clone = handleTest ./ft2-clone.nix {}; + legit = handleTest ./legit.nix {}; mimir = handleTest ./mimir.nix {}; garage = handleTest ./garage {}; gemstash = handleTest ./gemstash.nix {}; diff --git a/nixos/tests/legit.nix b/nixos/tests/legit.nix new file mode 100644 index 000000000000..3eb3f5035699 --- /dev/null +++ b/nixos/tests/legit.nix @@ -0,0 +1,54 @@ +import ./make-test-python.nix ({ lib, pkgs, ... }: +let + port = 5000; + scanPath = "/var/lib/legit"; +in +{ + name = "legit-web"; + meta.maintainers = [ lib.maintainers.ratsclub ]; + + nodes = { + server = { config, pkgs }: { + services.legit = { + enable = true; + settings = { + server.port = 5000; + repo = { inherit scanPath; }; + }; + }; + + environment.systemPackages = [ pkgs.git ]; + }; + }; + + testScript = { nodes, ... }: + let + strPort = builtins.toString port; + in + '' + start_all() + + server.wait_for_unit("network.target") + server.wait_for_unit("legit.service") + + server.wait_until_succeeds( + "curl -f http://localhost:${strPort}" + ) + + server.succeed("${pkgs.writeShellScript "setup-legit-test-repo" '' + set -e + git init --bare -b master ${scanPath}/some-repo + git init -b master reference + cd reference + git remote add origin ${scanPath}/some-repo + date > date.txt + git add date.txt + git -c user.name=test -c user.email=test@localhost commit -m 'add date' + git push -u origin master + ''}") + + server.wait_until_succeeds( + "curl -f http://localhost:${strPort}/some-repo" + ) + ''; +})