at 25.11-pre 2.3 kB view raw
1import ./make-test-python.nix ( 2 { pkgs, ... }: 3 4 let 5 hashes = pkgs.writeText "hashes" '' 6 b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c /project/bar 7 ''; 8 in 9 { 10 name = "gitdaemon"; 11 12 meta = with pkgs.lib.maintainers; { 13 maintainers = [ tilpner ]; 14 }; 15 16 nodes = { 17 server = 18 { config, ... }: 19 { 20 networking.firewall.allowedTCPPorts = [ config.services.gitDaemon.port ]; 21 22 environment.systemPackages = [ pkgs.git ]; 23 24 systemd.tmpfiles.rules = [ 25 # type path mode user group age arg 26 " d /git 0755 git git - -" 27 ]; 28 29 services.gitDaemon = { 30 enable = true; 31 basePath = "/git"; 32 }; 33 }; 34 35 client = 36 { pkgs, ... }: 37 { 38 environment.systemPackages = [ pkgs.git ]; 39 }; 40 }; 41 42 testScript = '' 43 start_all() 44 45 with subtest("create project.git"): 46 server.succeed( 47 "git init --bare /git/project.git", 48 "touch /git/project.git/git-daemon-export-ok", 49 ) 50 51 with subtest("add file to project.git"): 52 server.succeed( 53 "git clone /git/project.git /project", 54 "echo foo > /project/bar", 55 "git config --global user.email 'you@example.com'", 56 "git config --global user.name 'Your Name'", 57 "git -C /project add bar", 58 "git -C /project commit -m 'quux'", 59 "git -C /project push", 60 "rm -r /project", 61 ) 62 63 # Change user/group to default daemon user/group from module 64 # to avoid "fatal: detected dubious ownership in repository at '/git/project.git'" 65 server.succeed("chown git:git -R /git/project.git") 66 67 with subtest("git daemon starts"): 68 server.wait_for_unit("git-daemon.service") 69 70 71 server.systemctl("start network-online.target") 72 client.systemctl("start network-online.target") 73 server.wait_for_unit("network-online.target") 74 client.wait_for_unit("network-online.target") 75 76 with subtest("client can clone project.git"): 77 client.succeed( 78 "git clone git://server/project.git /project", 79 "sha256sum -c ${hashes}", 80 ) 81 ''; 82 } 83)