···
1
-
import ./make-test-python.nix (
4
-
robotsTxt = pkgs.writeText "cgit-robots.txt" ''
11
-
meta = with pkgs.lib.maintainers; {
12
-
maintainers = [ schnusch ];
3
+
robotsTxt = pkgs.writeText "cgit-robots.txt" ''
10
+
meta = with pkgs.lib.maintainers; {
11
+
maintainers = [ schnusch ];
19
-
services.cgit."localhost" = {
21
-
package = pkgs.cgit.overrideAttrs (
22
-
{ postInstall, ... }:
26
-
cp ${robotsTxt} "$out/cgit/robots.txt"
30
-
nginx.location = "/(c)git/";
33
-
path = "/tmp/git/some-repo";
34
-
desc = "some-repo description";
18
+
services.cgit."localhost" = {
20
+
package = pkgs.cgit.overrideAttrs (
21
+
{ postInstall, ... }:
25
+
cp ${robotsTxt} "$out/cgit/robots.txt"
29
+
nginx.location = "/(c)git/";
32
+
path = "/tmp/git/some-repo";
33
+
desc = "some-repo description";
45
-
environment.systemPackages = [ pkgs.git ];
44
+
environment.systemPackages = [ pkgs.git ];
54
-
server.wait_for_unit("nginx.service")
55
-
server.wait_for_unit("network.target")
56
-
server.wait_for_open_port(80)
58
-
server.succeed("curl -fsS http://localhost/%28c%29git/cgit.css")
53
+
server.wait_for_unit("nginx.service")
54
+
server.wait_for_unit("network.target")
55
+
server.wait_for_open_port(80)
60
-
server.succeed("curl -fsS http://localhost/%28c%29git/robots.txt | diff -u - ${robotsTxt}")
57
+
server.succeed("curl -fsS http://localhost/%28c%29git/cgit.css")
63
-
"curl -fsS http://localhost/%28c%29git/ | grep -F 'some-repo description'"
59
+
server.succeed("curl -fsS http://localhost/%28c%29git/robots.txt | diff -u - ${robotsTxt}")
66
-
server.fail("curl -fsS http://localhost/robots.txt")
62
+
"curl -fsS http://localhost/%28c%29git/ | grep -F 'some-repo description'"
68
-
server.succeed("sudo -u cgit ${pkgs.writeShellScript "setup-cgit-test-repo" ''
70
-
git init --bare -b master /tmp/git/some-repo
71
-
git init -b master reference
73
-
git remote add origin /tmp/git/some-repo
74
-
{ echo -n "cgit NixOS Test at "; date; } > date.txt
76
-
git -c user.name=test -c user.email=test@localhost commit -m 'add date'
77
-
git push -u origin master
65
+
server.fail("curl -fsS http://localhost/robots.txt")
82
-
"curl -fsS 'http://localhost/%28c%29git/some-repo/plain/date.txt?id=master' | diff -u reference/date.txt -"
67
+
server.succeed("sudo -u cgit ${pkgs.writeShellScript "setup-cgit-test-repo" ''
69
+
git init --bare -b master /tmp/git/some-repo
70
+
git init -b master reference
72
+
git remote add origin /tmp/git/some-repo
73
+
{ echo -n "cgit NixOS Test at "; date; } > date.txt
75
+
git -c user.name=test -c user.email=test@localhost commit -m 'add date'
76
+
git push -u origin master
87
-
"git clone http://localhost/%28c%29git/some-repo && diff -u reference/date.txt some-repo/date.txt"
81
+
"curl -fsS 'http://localhost/%28c%29git/some-repo/plain/date.txt?id=master' | diff -u reference/date.txt -"
90
-
# test list settings by greping for the fallback readme
92
-
"curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F 'cgit NixOS Test at'"
86
+
"git clone http://localhost/%28c%29git/some-repo && diff -u reference/date.txt some-repo/date.txt"
96
-
server.succeed("sudo -u cgit ${pkgs.writeShellScript "cgit-commit-readme" ''
98
-
echo '# cgit NixOS test README' > reference/README.md
99
-
git -C reference add README.md
100
-
git -C reference -c user.name=test -c user.email=test@localhost commit -m 'add readme'
101
-
git -C reference push
89
+
# test list settings by greping for the fallback readme
91
+
"curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F 'cgit NixOS Test at'"
104
-
# test list settings by greping for the real readme
106
-
"curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F '# cgit NixOS test README'"
109
-
"curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F 'cgit NixOS Test at'"
95
+
server.succeed("sudo -u cgit ${pkgs.writeShellScript "cgit-commit-readme" ''
97
+
echo '# cgit NixOS test README' > reference/README.md
98
+
git -C reference add README.md
99
+
git -C reference -c user.name=test -c user.email=test@localhost commit -m 'add readme'
100
+
git -C reference push
103
+
# test list settings by greping for the real readme
105
+
"curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F '# cgit NixOS test README'"
108
+
"curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F 'cgit NixOS Test at'"