1 import ./make-test-python.nix ({ pkgs, ... }:
3 robotsTxt = pkgs.writeText "cgit-robots.txt" ''
9 meta = with pkgs.lib.maintainers; {
10 maintainers = [ schnusch ];
15 services.cgit."localhost" = {
17 package = pkgs.cgit.overrideAttrs ({ postInstall, ... }: {
20 cp ${robotsTxt} "$out/cgit/robots.txt"
23 nginx.location = "/(c)git/";
26 path = "/tmp/git/some-repo";
27 desc = "some-repo description";
38 environment.systemPackages = [ pkgs.git ];
42 testScript = { nodes, ... }: ''
45 server.wait_for_unit("nginx.service")
46 server.wait_for_unit("network.target")
47 server.wait_for_open_port(80)
49 server.succeed("curl -fsS http://localhost/%28c%29git/cgit.css")
51 server.succeed("curl -fsS http://localhost/%28c%29git/robots.txt | diff -u - ${robotsTxt}")
54 "curl -fsS http://localhost/%28c%29git/ | grep -F 'some-repo description'"
57 server.fail("curl -fsS http://localhost/robots.txt")
59 server.succeed("sudo -u cgit ${pkgs.writeShellScript "setup-cgit-test-repo" ''
61 git init --bare -b master /tmp/git/some-repo
62 git init -b master reference
64 git remote add origin /tmp/git/some-repo
65 { echo -n "cgit NixOS Test at "; date; } > date.txt
67 git -c user.name=test -c user.email=test@localhost commit -m 'add date'
68 git push -u origin master
73 "curl -fsS 'http://localhost/%28c%29git/some-repo/plain/date.txt?id=master' | diff -u reference/date.txt -"
78 "git clone http://localhost/%28c%29git/some-repo && diff -u reference/date.txt some-repo/date.txt"
81 # test list settings by greping for the fallback readme
83 "curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F 'cgit NixOS Test at'"
87 server.succeed("sudo -u cgit ${pkgs.writeShellScript "cgit-commit-readme" ''
89 echo '# cgit NixOS test README' > reference/README.md
90 git -C reference add README.md
91 git -C reference -c user.name=test -c user.email=test@localhost commit -m 'add readme'
95 # test list settings by greping for the real readme
97 "curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F '# cgit NixOS test README'"
100 "curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F 'cgit NixOS Test at'"