|
1 | | -import ./make-test-python.nix ( |
2 | | - { pkgs, ... }: |
3 | | - let |
4 | | - robotsTxt = pkgs.writeText "cgit-robots.txt" '' |
5 | | - User-agent: * |
6 | | - Disallow: / |
7 | | - ''; |
8 | | - in |
9 | | - { |
10 | | - name = "cgit"; |
11 | | - meta = with pkgs.lib.maintainers; { |
12 | | - maintainers = [ schnusch ]; |
13 | | - }; |
| 1 | +{ pkgs, ... }: |
| 2 | +let |
| 3 | + robotsTxt = pkgs.writeText "cgit-robots.txt" '' |
| 4 | + User-agent: * |
| 5 | + Disallow: / |
| 6 | + ''; |
| 7 | +in |
| 8 | +{ |
| 9 | + name = "cgit"; |
| 10 | + meta = with pkgs.lib.maintainers; { |
| 11 | + maintainers = [ schnusch ]; |
| 12 | + }; |
14 | 13 |
|
15 | | - nodes = { |
16 | | - server = |
17 | | - { ... }: |
18 | | - { |
19 | | - services.cgit."localhost" = { |
20 | | - enable = true; |
21 | | - package = pkgs.cgit.overrideAttrs ( |
22 | | - { postInstall, ... }: |
23 | | - { |
24 | | - postInstall = '' |
25 | | - ${postInstall} |
26 | | - cp ${robotsTxt} "$out/cgit/robots.txt" |
27 | | - ''; |
28 | | - } |
29 | | - ); |
30 | | - nginx.location = "/(c)git/"; |
31 | | - repos = { |
32 | | - some-repo = { |
33 | | - path = "/tmp/git/some-repo"; |
34 | | - desc = "some-repo description"; |
35 | | - }; |
36 | | - }; |
37 | | - settings = { |
38 | | - readme = [ |
39 | | - ":README.md" |
40 | | - ":date.txt" |
41 | | - ]; |
| 14 | + nodes = { |
| 15 | + server = |
| 16 | + { ... }: |
| 17 | + { |
| 18 | + services.cgit."localhost" = { |
| 19 | + enable = true; |
| 20 | + package = pkgs.cgit.overrideAttrs ( |
| 21 | + { postInstall, ... }: |
| 22 | + { |
| 23 | + postInstall = '' |
| 24 | + ${postInstall} |
| 25 | + cp ${robotsTxt} "$out/cgit/robots.txt" |
| 26 | + ''; |
| 27 | + } |
| 28 | + ); |
| 29 | + nginx.location = "/(c)git/"; |
| 30 | + repos = { |
| 31 | + some-repo = { |
| 32 | + path = "/tmp/git/some-repo"; |
| 33 | + desc = "some-repo description"; |
42 | 34 | }; |
43 | 35 | }; |
44 | | - |
45 | | - environment.systemPackages = [ pkgs.git ]; |
| 36 | + settings = { |
| 37 | + readme = [ |
| 38 | + ":README.md" |
| 39 | + ":date.txt" |
| 40 | + ]; |
| 41 | + }; |
46 | 42 | }; |
47 | | - }; |
48 | 43 |
|
49 | | - testScript = |
50 | | - { nodes, ... }: |
51 | | - '' |
52 | | - start_all() |
| 44 | + environment.systemPackages = [ pkgs.git ]; |
| 45 | + }; |
| 46 | + }; |
| 47 | + |
| 48 | + testScript = |
| 49 | + { nodes, ... }: |
| 50 | + '' |
| 51 | + start_all() |
53 | 52 |
|
54 | | - server.wait_for_unit("nginx.service") |
55 | | - server.wait_for_unit("network.target") |
56 | | - server.wait_for_open_port(80) |
| 53 | + server.wait_for_unit("nginx.service") |
| 54 | + server.wait_for_unit("network.target") |
| 55 | + server.wait_for_open_port(80) |
57 | 56 |
|
58 | | - server.succeed("curl -fsS http://localhost/%28c%29git/cgit.css") |
| 57 | + server.succeed("curl -fsS http://localhost/%28c%29git/cgit.css") |
59 | 58 |
|
60 | | - server.succeed("curl -fsS http://localhost/%28c%29git/robots.txt | diff -u - ${robotsTxt}") |
| 59 | + server.succeed("curl -fsS http://localhost/%28c%29git/robots.txt | diff -u - ${robotsTxt}") |
61 | 60 |
|
62 | | - server.succeed( |
63 | | - "curl -fsS http://localhost/%28c%29git/ | grep -F 'some-repo description'" |
64 | | - ) |
| 61 | + server.succeed( |
| 62 | + "curl -fsS http://localhost/%28c%29git/ | grep -F 'some-repo description'" |
| 63 | + ) |
65 | 64 |
|
66 | | - server.fail("curl -fsS http://localhost/robots.txt") |
| 65 | + server.fail("curl -fsS http://localhost/robots.txt") |
67 | 66 |
|
68 | | - server.succeed("sudo -u cgit ${pkgs.writeShellScript "setup-cgit-test-repo" '' |
69 | | - set -e |
70 | | - git init --bare -b master /tmp/git/some-repo |
71 | | - git init -b master reference |
72 | | - cd reference |
73 | | - git remote add origin /tmp/git/some-repo |
74 | | - { echo -n "cgit NixOS Test at "; date; } > date.txt |
75 | | - git add date.txt |
76 | | - git -c user.name=test -c user.email=test@localhost commit -m 'add date' |
77 | | - git push -u origin master |
78 | | - ''}") |
| 67 | + server.succeed("sudo -u cgit ${pkgs.writeShellScript "setup-cgit-test-repo" '' |
| 68 | + set -e |
| 69 | + git init --bare -b master /tmp/git/some-repo |
| 70 | + git init -b master reference |
| 71 | + cd reference |
| 72 | + git remote add origin /tmp/git/some-repo |
| 73 | + { echo -n "cgit NixOS Test at "; date; } > date.txt |
| 74 | + git add date.txt |
| 75 | + git -c user.name=test -c user.email=test@localhost commit -m 'add date' |
| 76 | + git push -u origin master |
| 77 | + ''}") |
79 | 78 |
|
80 | | - # test web download |
81 | | - server.succeed( |
82 | | - "curl -fsS 'http://localhost/%28c%29git/some-repo/plain/date.txt?id=master' | diff -u reference/date.txt -" |
83 | | - ) |
| 79 | + # test web download |
| 80 | + server.succeed( |
| 81 | + "curl -fsS 'http://localhost/%28c%29git/some-repo/plain/date.txt?id=master' | diff -u reference/date.txt -" |
| 82 | + ) |
84 | 83 |
|
85 | | - # test http clone |
86 | | - server.succeed( |
87 | | - "git clone http://localhost/%28c%29git/some-repo && diff -u reference/date.txt some-repo/date.txt" |
88 | | - ) |
| 84 | + # test http clone |
| 85 | + server.succeed( |
| 86 | + "git clone http://localhost/%28c%29git/some-repo && diff -u reference/date.txt some-repo/date.txt" |
| 87 | + ) |
89 | 88 |
|
90 | | - # test list settings by greping for the fallback readme |
91 | | - server.succeed( |
92 | | - "curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F 'cgit NixOS Test at'" |
93 | | - ) |
| 89 | + # test list settings by greping for the fallback readme |
| 90 | + server.succeed( |
| 91 | + "curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F 'cgit NixOS Test at'" |
| 92 | + ) |
94 | 93 |
|
95 | | - # add real readme |
96 | | - server.succeed("sudo -u cgit ${pkgs.writeShellScript "cgit-commit-readme" '' |
97 | | - set -e |
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 |
102 | | - ''}") |
| 94 | + # add real readme |
| 95 | + server.succeed("sudo -u cgit ${pkgs.writeShellScript "cgit-commit-readme" '' |
| 96 | + set -e |
| 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 |
| 101 | + ''}") |
103 | 102 |
|
104 | | - # test list settings by greping for the real readme |
105 | | - server.succeed( |
106 | | - "curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F '# cgit NixOS test README'" |
107 | | - ) |
108 | | - server.fail( |
109 | | - "curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F 'cgit NixOS Test at'" |
110 | | - ) |
111 | | - ''; |
112 | | - } |
113 | | -) |
| 103 | + # test list settings by greping for the real readme |
| 104 | + server.succeed( |
| 105 | + "curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F '# cgit NixOS test README'" |
| 106 | + ) |
| 107 | + server.fail( |
| 108 | + "curl -fsS 'http://localhost/%28c%29git/some-repo/about/' | grep -F 'cgit NixOS Test at'" |
| 109 | + ) |
| 110 | + ''; |
| 111 | +} |
0 commit comments