netlify-cli: Add test
This commit is contained in:
parent
f65b1451a0
commit
d4da59708c
2 changed files with 39 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
{ pkgs, lib, fetchFromGitHub }:
|
||||
{ callPackage, fetchFromGitHub, lib, pkgs }:
|
||||
let
|
||||
nodePackages = import ./composition.nix { inherit pkgs; };
|
||||
in
|
||||
|
@ -9,5 +9,6 @@ in
|
|||
src = fetchFromGitHub (builtins.fromJSON (builtins.readFile ./netlify-cli.json));
|
||||
bypassCache = true;
|
||||
reconstructLock = true;
|
||||
passthru.tests.test = callPackage ./test.nix { };
|
||||
meta.maintainers = with lib.maintainers; [ roberth ];
|
||||
}
|
||||
|
|
37
pkgs/development/web/netlify-cli/test.nix
Normal file
37
pkgs/development/web/netlify-cli/test.nix
Normal file
|
@ -0,0 +1,37 @@
|
|||
{
|
||||
curl,
|
||||
netlify-cli,
|
||||
runCommand,
|
||||
}:
|
||||
|
||||
runCommand "netlify-cli-test" {
|
||||
nativeBuildInputs = [
|
||||
netlify-cli
|
||||
curl
|
||||
];
|
||||
meta.timeout = 600;
|
||||
} ''
|
||||
mkdir home
|
||||
export HOME=$PWD/home
|
||||
|
||||
# Create a simple site
|
||||
echo '<h1>hi</h1>' >index.html
|
||||
echo '/with-redirect /' >_redirects
|
||||
|
||||
# Start a local server and wait for it to respond
|
||||
netlify dev --offline --port 8888 2>&1 | tee log &
|
||||
sleep 0.1 || true
|
||||
for (( i=0; i<300; i++ )); do
|
||||
if grep --ignore-case 'Server now ready' <log; then
|
||||
break
|
||||
else
|
||||
sleep 1
|
||||
fi
|
||||
done
|
||||
|
||||
# Test the local server
|
||||
curl -L http://localhost:8888/with-redirect | grep '<h1>hi</h1>'
|
||||
|
||||
# Success
|
||||
touch $out
|
||||
''
|
Loading…
Reference in a new issue