diff --git a/pkgs/development/web/netlify-cli/default.nix b/pkgs/development/web/netlify-cli/default.nix index 8b991faf07d4..f16cce4c1511 100644 --- a/pkgs/development/web/netlify-cli/default.nix +++ b/pkgs/development/web/netlify-cli/default.nix @@ -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 ]; } diff --git a/pkgs/development/web/netlify-cli/test.nix b/pkgs/development/web/netlify-cli/test.nix new file mode 100644 index 000000000000..22e97e332189 --- /dev/null +++ b/pkgs/development/web/netlify-cli/test.nix @@ -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 '

hi

' >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' hi' + + # Success + touch $out +''