diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2019-12-26 18:03:39 +0100 |
---|---|---|
committer | Maximilian Bosch <maximilian@mbosch.me> | 2019-12-26 18:50:38 +0100 |
commit | c5c7ccf022559bd3c40506786a1ffba1b28a08d0 (patch) | |
tree | 692b1e4bfac9de96e9a067e65cc332911707682f /nixos/tests/nginx.nix | |
parent | 495b0b581c53cc36e788a1345963f5b1427deabd (diff) | |
download | nixpkgs-c5c7ccf022559bd3c40506786a1ffba1b28a08d0.tar nixpkgs-c5c7ccf022559bd3c40506786a1ffba1b28a08d0.tar.gz nixpkgs-c5c7ccf022559bd3c40506786a1ffba1b28a08d0.tar.bz2 nixpkgs-c5c7ccf022559bd3c40506786a1ffba1b28a08d0.tar.lz nixpkgs-c5c7ccf022559bd3c40506786a1ffba1b28a08d0.tar.xz nixpkgs-c5c7ccf022559bd3c40506786a1ffba1b28a08d0.tar.zst nixpkgs-c5c7ccf022559bd3c40506786a1ffba1b28a08d0.zip |
nixos/nginx: fix test
When using format-strings, curly brackets need to be escaped using `{{` to avoid errors from python. And apparently, Perl's `==` is used to compare substrings[1] which is why the translation to `assert http_code == "304"` failed as the string contains several headers from curl. [1] Just check `perl <(echo 'die "alarm" if "foo\n304" == 304')`
Diffstat (limited to 'nixos/tests/nginx.nix')
-rw-r--r-- | nixos/tests/nginx.nix | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/nixos/tests/nginx.nix b/nixos/tests/nginx.nix index 24e85d77c88..55d2c930908 100644 --- a/nixos/tests/nginx.nix +++ b/nixos/tests/nginx.nix @@ -73,11 +73,13 @@ import ./make-test-python.nix ({ pkgs, ... }: { def check_etag(): - etag = webserver.succeed(f'curl -v {url} 2>&1 | sed -n -e "s/^< etag: *//ip"') + etag = webserver.succeed( + f'curl -v {url} 2>&1 | sed -n -e "s/^< etag: *//ip"' + ).rstrip() http_code = webserver.succeed( - f"curl -w '%{http_code}' -X HEAD -H 'If-None-Match: {etag}' {url}" + f"curl -w '%{{http_code}}' --head --fail -H 'If-None-Match: {etag}' {url}" ) - assert http_code == "304" + assert http_code.split("\n")[-1] == "304" return etag @@ -90,6 +92,7 @@ import ./make-test-python.nix ({ pkgs, ... }: { webserver.succeed( "${etagSystem}/bin/switch-to-configuration test >&2" ) + webserver.sleep(1) new_etag = check_etag() assert old_etag != new_etag |