Mercurial > hg > nginx-tests
comparison map_complex.t @ 927:6afbb809983b
Tests: map module basic tests with complex value.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Fri, 13 May 2016 18:26:17 +0300 |
parents | |
children | 856a37b4f47d |
comparison
equal
deleted
inserted
replaced
926:16b5438e3da4 | 927:6afbb809983b |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Sergey Kandaurov | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for map module with complex value. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 | |
20 ############################################################################### | |
21 | |
22 select STDERR; $| = 1; | |
23 select STDOUT; $| = 1; | |
24 | |
25 my $t = Test::Nginx->new()->has(qw/http map rewrite/); | |
26 | |
27 $t->write_file_expand('nginx.conf', <<'EOF'); | |
28 | |
29 %%TEST_GLOBALS%% | |
30 | |
31 daemon off; | |
32 | |
33 events { | |
34 } | |
35 | |
36 http { | |
37 %%TEST_GLOBALS_HTTP%% | |
38 | |
39 map $args $x { | |
40 var foo:$y; | |
41 var2 $y:foo; | |
42 default foo:$y; | |
43 } | |
44 | |
45 map $args $y { | |
46 default bar; | |
47 same baz; | |
48 } | |
49 | |
50 server { | |
51 listen 127.0.0.1:8080; | |
52 server_name localhost; | |
53 | |
54 location / { | |
55 add_header X-Foo $x; | |
56 return 204; | |
57 } | |
58 } | |
59 } | |
60 | |
61 EOF | |
62 | |
63 $t->try_run('no complex value')->plan(3); | |
64 | |
65 ############################################################################### | |
66 | |
67 like(http_get('/?var'), qr/foo:bar/, 'map cv'); | |
68 like(http_get('/?var2'), qr/bar:foo/, 'map cv 2'); | |
69 like(http_get('/?same'), qr/foo:baz/, 'map cv key'); | |
70 | |
71 ############################################################################### |