Skip to content

Commit

Permalink
tests: Fix routing tests in the no njs case
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
ac000 committed Sep 10, 2024
1 parent 46ddb01 commit 6976a61
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions test/test_routing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -2055,7 +2056,21 @@ def try_if(condition, status):
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
Expand Down

0 comments on commit 6976a61

Please sign in to comment.