comparison sub_filter.t @ 575:eea2b0158b51

Tests: sub filter tests for complex variable.
author Sergey Kandaurov <pluknet@nginx.com>
date Thu, 14 May 2015 17:04:42 +0300
parents 907e89fba9c3
children 8504a62496df
comparison
equal deleted inserted replaced
574:2cd00179f4b2 575:eea2b0158b51
19 ############################################################################### 19 ###############################################################################
20 20
21 select STDERR; $| = 1; 21 select STDERR; $| = 1;
22 select STDOUT; $| = 1; 22 select STDOUT; $| = 1;
23 23
24 my $t = Test::Nginx->new()->has(qw/http rewrite sub/)->plan(22) 24 my $t = Test::Nginx->new()->has(qw/http rewrite sub/)->plan(25)
25 ->write_file_expand('nginx.conf', <<'EOF'); 25 ->write_file_expand('nginx.conf', <<'EOF');
26 26
27 %%TEST_GLOBALS%% 27 %%TEST_GLOBALS%%
28 28
29 daemon off; 29 daemon off;
76 location /single/many { 76 location /single/many {
77 sub_filter A B; 77 sub_filter A B;
78 sub_filter_once off; 78 sub_filter_once off;
79 return 200 $arg_b; 79 return 200 $arg_b;
80 } 80 }
81
82 location /var/string {
83 sub_filter X$arg_a _replaced;
84 return 200 $arg_b;
85 }
86
87 location /var/replacement {
88 sub_filter aab '${arg_a}_replaced';
89 return 200 $arg_b;
90 }
81 } 91 }
82 } 92 }
83 93
84 EOF 94 EOF
85 95
114 like(http_get('/single/many?b=A'), qr/B/, 'single many only'); 124 like(http_get('/single/many?b=A'), qr/B/, 'single many only');
115 like(http_get('/single/many?b=AA'), qr/BB/, 'single many begin'); 125 like(http_get('/single/many?b=AA'), qr/BB/, 'single many begin');
116 like(http_get('/single/many?b=CAAC'), qr/CBBC/, 'single many middle'); 126 like(http_get('/single/many?b=CAAC'), qr/CBBC/, 'single many middle');
117 like(http_get('/single/many?b=CA'), qr/CB/, 'single many end'); 127 like(http_get('/single/many?b=CA'), qr/CB/, 'single many end');
118 128
129 TODO: {
130 local $TODO = 'not yet';
131
132 like(http_get('/var/string?a=foo&b=Xfoo'), qr/_replaced/, 'complex string');
133 like(http_get('/var/string?a=abcdefghijklmnopq&b=Xabcdefghijklmnopq'),
134 qr/_replaced/, 'complex string long');
135
136 }
137
138 like(http_get('/var/replacement?a=ee&b=aaab'), qr/aee_replaced/,
139 'complex replacement');
140
119 ############################################################################### 141 ###############################################################################