nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 71 lines 1.5 kB view raw
1{ 2 config, 3 hostPkgs, 4 lib, 5 ... 6}: 7let 8 sitePkg = hostPkgs.runCommand "site" { } '' 9 dist=$out/dist 10 mkdir -p $dist 11 echo "<html><body><a href=\"http://example/foo.html\">foo</a></body></html>" > $dist/index.html 12 echo "<html><body><a href=\".\">index</a></body></html>" > $dist/foo.html 13 ''; 14 check = config.node.pkgs.testers.lycheeLinkCheck { 15 site = sitePkg; 16 }; 17in 18{ 19 name = "testers-lychee-link-check-run"; 20 nodes.client = { ... }: { }; 21 nodes.example = { 22 networking.firewall.allowedTCPPorts = [ 80 ]; 23 services.nginx = { 24 enable = true; 25 virtualHosts."example" = { 26 locations."/" = { 27 root = "/var/www/example"; 28 index = "index.html"; 29 }; 30 }; 31 }; 32 33 }; 34 testScript = '' 35 start_all() 36 37 # SETUP 38 39 example.succeed(""" 40 mkdir -p /var/www/example 41 echo '<h1>hi</h1>' > /var/www/example/index.html 42 """) 43 client.wait_until_succeeds(""" 44 curl --fail -v http://example 45 """) 46 47 # FAILURE CASE 48 49 client.succeed(""" 50 exec 1>&2 51 r=0 52 ${lib.getExe check.online} || { 53 r=$? 54 } 55 if [[ $r -ne 2 ]]; then 56 echo "lycheeLinkCheck unexpected exit code $r" 57 exit 1 58 fi 59 """) 60 61 # SUCCESS CASE 62 63 example.succeed(""" 64 echo '<h1>foo</h1>' > /var/www/example/foo.html 65 """) 66 67 client.succeed(""" 68 ${lib.getExe check.online} 69 """) 70 ''; 71}