From 6976a614d782d13e14c6c8e446ce521c47f02b58 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Fri, 6 Sep 2024 16:24:32 +0100 Subject: 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 --- test/test_routing.py | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'test/test_routing.py') 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 -- cgit