diff options
author | Andrew Clayton <a.clayton@nginx.com> | 2024-09-06 16:24:32 +0100 |
---|---|---|
committer | Andrew Clayton <a.clayton@nginx.com> | 2024-09-10 01:12:29 +0100 |
commit | 6976a614d782d13e14c6c8e446ce521c47f02b58 (patch) | |
tree | 61875714e1f1eaf7a25f297d26190f6286c44055 | |
parent | 46ddb010379862b108879c471760252ad9bb3ad7 (diff) | |
download | unit-6976a614d782d13e14c6c8e446ce521c47f02b58.tar.gz unit-6976a614d782d13e14c6c8e446ce521c47f02b58.tar.bz2 |
tests: Fix routing tests in the no njs case
Don't try and run the tests that require njs if it isn't enabled.
Closes: https://github.com/nginx/unit/issues/1411
Fixes: 43c4bfdcd ("tests: "if" option in http route match")
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
-rw-r--r-- | test/test_routing.py | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/test/test_routing.py b/test/test_routing.py index c419779a..170f627e 100644 --- a/test/test_routing.py +++ b/test/test_routing.py @@ -2011,10 +2011,11 @@ def test_routes_match_destination_proxy(): assert client.get()['status'] == 200, 'proxy' -def test_routes_match_if(): +def set_if(condition): + assert 'success' in client.conf(f'"{condition}"', 'routes/0/match/if') + - def set_if(condition): - assert 'success' in client.conf(f'"{condition}"', 'routes/0/match/if') +def test_routes_match_if(): def try_if(condition, status): set_if(condition) @@ -2055,7 +2056,21 @@ def test_routes_match_if(): assert client.get(url='/foo_empty?foo')['status'] == 200 assert client.get(url='/foo?foo=1')['status'] == 404 - # njs +def test_routes_match_if_njs(require): + require({'modules': {'njs': 'any'}}) + + assert 'success' in client.conf( + { + "listeners": {"*:8080": {"pass": "routes"}}, + "routes": [ + { + "match": {"method": "GET"}, + "action": {"return": 200}, + } + ], + "applications": {}, + } + ) set_if('`${args.foo == \'1\'}`') assert client.get(url='/foo_1?foo=1')['status'] == 200 |