diff options
author | Henri Menke <henri@henrimenke.de> | 2022-09-18 14:54:04 +0200 |
---|---|---|
committer | Henri Menke <henri@henrimenke.de> | 2022-11-05 21:40:57 +0100 |
commit | 9ab02e1ec6e7a9a44a087a8b131e65f77e924c0d (patch) | |
tree | 799fe456a078732550eea0b2340bf4d49be72d67 /nixos/tests/nginx-njs.nix | |
parent | 830a385b5f3f9a03c4f44f08071c655f9d85c2b3 (diff) |
nginxModules.njs: init at 0.7.8
Diffstat (limited to 'nixos/tests/nginx-njs.nix')
-rw-r--r-- | nixos/tests/nginx-njs.nix | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/nixos/tests/nginx-njs.nix b/nixos/tests/nginx-njs.nix new file mode 100644 index 0000000000000..72be16384f1b3 --- /dev/null +++ b/nixos/tests/nginx-njs.nix @@ -0,0 +1,27 @@ +import ./make-test-python.nix ({ pkgs, lib, ... }: { + name = "nginx-njs"; + + nodes.machine = { config, lib, pkgs, ... }: { + services.nginx = { + enable = true; + additionalModules = [ pkgs.nginxModules.njs ]; + commonHttpConfig = '' + js_import http from ${builtins.toFile "http.js" '' + function hello(r) { + r.return(200, "Hello world!"); + } + export default {hello}; + ''}; + ''; + virtualHosts."localhost".locations."/".extraConfig = '' + js_content http.hello; + ''; + }; + }; + testScript = '' + machine.wait_for_unit("nginx") + + response = machine.wait_until_succeeds("curl -fvvv -s http://127.0.0.1/") + assert "Hello world!" == response, f"Expected 'Hello world!', got '{response}'" + ''; +}) |