Mercurial > hg > nginx-tests
comparison map.t @ 926:16b5438e3da4
Tests: added map test with matching hash key.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 13 May 2016 18:19:44 +0300 |
parents | 1f8e15e1899a |
children | e9064d691790 |
comparison
equal
deleted
inserted
replaced
925:6bb1f2ccd386 | 926:16b5438e3da4 |
---|---|
21 ############################################################################### | 21 ############################################################################### |
22 | 22 |
23 select STDERR; $| = 1; | 23 select STDERR; $| = 1; |
24 select STDOUT; $| = 1; | 24 select STDOUT; $| = 1; |
25 | 25 |
26 my $t = Test::Nginx->new()->has(qw/http map rewrite/)->plan(18); | 26 my $t = Test::Nginx->new()->has(qw/http map rewrite/)->plan(19); |
27 | 27 |
28 $t->write_file_expand('nginx.conf', <<'EOF'); | 28 $t->write_file_expand('nginx.conf', <<'EOF'); |
29 | 29 |
30 %%TEST_GLOBALS%% | 30 %%TEST_GLOBALS%% |
31 | 31 |
38 %%TEST_GLOBALS_HTTP%% | 38 %%TEST_GLOBALS_HTTP%% |
39 | 39 |
40 map $args $x { | 40 map $args $x { |
41 default 0; | 41 default 0; |
42 foo bar; | 42 foo bar; |
43 foo2 bar; | |
43 } | 44 } |
44 | 45 |
45 map $args $y { | 46 map $args $y { |
46 hostnames; | 47 hostnames; |
47 default 0; | 48 default 0; |
84 | 85 |
85 ############################################################################### | 86 ############################################################################### |
86 | 87 |
87 like(http_get('/?1'), qr/x:0 y:0/, 'map default'); | 88 like(http_get('/?1'), qr/x:0 y:0/, 'map default'); |
88 like(http_get('/?foo'), qr/x:bar y:0/, 'map foo bar'); | 89 like(http_get('/?foo'), qr/x:bar y:0/, 'map foo bar'); |
90 like(http_get('/?foo2'), qr/x:bar y:0/, 'map foo bar key'); | |
89 like(http_get('/?example.com'), qr/x:0 y:foo/, 'map example.com foo'); | 91 like(http_get('/?example.com'), qr/x:0 y:foo/, 'map example.com foo'); |
90 like(http_get('/?EXAMPLE.COM'), qr/x:0 y:foo/, 'map EXAMPLE.COM foo'); | 92 like(http_get('/?EXAMPLE.COM'), qr/x:0 y:foo/, 'map EXAMPLE.COM foo'); |
91 like(http_get('/?example.com.'), qr/x:0 y:foo/, 'map example.com. foo'); | 93 like(http_get('/?example.com.'), qr/x:0 y:foo/, 'map example.com. foo'); |
92 like(http_get('/?example.org'), qr/x:0 y:right-wildcard/, | 94 like(http_get('/?example.org'), qr/x:0 y:right-wildcard/, |
93 'map example.org wildcard'); | 95 'map example.org wildcard'); |