Skip to content

Commit 6976a61

Browse files
committed
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: #1411 Fixes: 43c4bfd ("tests: "if" option in http route match") Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
1 parent 46ddb01 commit 6976a61

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

test/test_routing.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,10 +2011,11 @@ def test_routes_match_destination_proxy():
20112011
assert client.get()['status'] == 200, 'proxy'
20122012

20132013

2014-
def test_routes_match_if():
2014+
def set_if(condition):
2015+
assert 'success' in client.conf(f'"{condition}"', 'routes/0/match/if')
2016+
20152017

2016-
def set_if(condition):
2017-
assert 'success' in client.conf(f'"{condition}"', 'routes/0/match/if')
2018+
def test_routes_match_if():
20182019

20192020
def try_if(condition, status):
20202021
set_if(condition)
@@ -2055,7 +2056,21 @@ def try_if(condition, status):
20552056
assert client.get(url='/foo_empty?foo')['status'] == 200
20562057
assert client.get(url='/foo?foo=1')['status'] == 404
20572058

2058-
# njs
2059+
def test_routes_match_if_njs(require):
2060+
require({'modules': {'njs': 'any'}})
2061+
2062+
assert 'success' in client.conf(
2063+
{
2064+
"listeners": {"*:8080": {"pass": "routes"}},
2065+
"routes": [
2066+
{
2067+
"match": {"method": "GET"},
2068+
"action": {"return": 200},
2069+
}
2070+
],
2071+
"applications": {},
2072+
}
2073+
)
20592074

20602075
set_if('`${args.foo == \'1\'}`')
20612076
assert client.get(url='/foo_1?foo=1')['status'] == 200

0 commit comments

Comments
 (0)