Files
nixpkgs/pkgs/by-name/ly/lychee/tests/network.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

72 lines
1.4 KiB
Nix

{
config,
hostPkgs,
lib,
...
}:
let
sitePkg = hostPkgs.runCommand "site" { } ''
dist=$out/dist
mkdir -p $dist
echo "<html><body><a href=\"http://example/foo.html\">foo</a></body></html>" > $dist/index.html
echo "<html><body><a href=\".\">index</a></body></html>" > $dist/foo.html
'';
check = config.node.pkgs.testers.lycheeLinkCheck {
site = sitePkg;
};
in
{
name = "testers-lychee-link-check-run";
nodes.client = { ... }: { };
nodes.example = {
networking.firewall.allowedTCPPorts = [ 80 ];
services.nginx = {
enable = true;
virtualHosts."example" = {
locations."/" = {
root = "/var/www/example";
index = "index.html";
};
};
};
};
testScript = ''
start_all()
# SETUP
example.succeed("""
mkdir -p /var/www/example
echo '<h1>hi</h1>' > /var/www/example/index.html
""")
client.wait_until_succeeds("""
curl --fail -v http://example
""")
# FAILURE CASE
client.succeed("""
exec 1>&2
r=0
${lib.getExe check.online} || {
r=$?
}
if [[ $r -ne 2 ]]; then
echo "lycheeLinkCheck unexpected exit code $r"
exit 1
fi
""")
# SUCCESS CASE
example.succeed("""
echo '<h1>foo</h1>' > /var/www/example/foo.html
""")
client.succeed("""
${lib.getExe check.online}
""")
'';
}