comparison js.t @ 1525:ca0858ef7d3d

Tests: added js keys tests.
author Dmitry Volyntsev <xeioex@nginx.com>
date Tue, 22 Oct 2019 21:05:51 +0300
parents 9521130f6f22
children 0411d30859ad
comparison
equal deleted inserted replaced
1524:9bc1ca067449 1525:ca0858ef7d3d
113 113
114 location /return_method { 114 location /return_method {
115 js_content return_method; 115 js_content return_method;
116 } 116 }
117 117
118 location /arg_keys {
119 js_content arg_keys;
120 }
121
118 location /log { 122 location /log {
119 return 200 $test_log; 123 return 200 $test_log;
120 } 124 }
121 125
122 location /except { 126 location /except {
211 215
212 function return_method(r) { 216 function return_method(r) {
213 r.return(Number(r.args.c), r.args.t); 217 r.return(Number(r.args.c), r.args.t);
214 } 218 }
215 219
220 function arg_keys(r) {
221 r.return(200, Object.keys(r.args).sort());
222 }
223
216 function test_log(r) { 224 function test_log(r) {
217 r.log('SEE-THIS'); 225 r.log('SEE-THIS');
218 } 226 }
219 227
220 function test_except(r) { 228 function test_except(r) {
230 function content_empty(r) { 238 function content_empty(r) {
231 } 239 }
232 240
233 EOF 241 EOF
234 242
235 $t->try_run('no njs available')->plan(26); 243 $t->try_run('no njs available')->plan(27);
236 244
237 ############################################################################### 245 ###############################################################################
238 246
239 247
240 like(http_get('/method'), qr/method=GET/, 'r.method'); 248 like(http_get('/method'), qr/method=GET/, 'r.method');
267 'return text'); 275 'return text');
268 like(http_get('/return_method?c=301&t=path'), qr/ 301 .*Location: path/s, 276 like(http_get('/return_method?c=301&t=path'), qr/ 301 .*Location: path/s,
269 'return redirect'); 277 'return redirect');
270 like(http_get('/return_method?c=404'), qr/404 Not.*html/s, 'return error page'); 278 like(http_get('/return_method?c=404'), qr/404 Not.*html/s, 'return error page');
271 like(http_get('/return_method?c=inv'), qr/ 500 /, 'return invalid'); 279 like(http_get('/return_method?c=inv'), qr/ 500 /, 'return invalid');
280
281 TODO: {
282 local $TODO = 'not yet'
283 unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.3.7';
284
285 like(http_get('/arg_keys?b=1&c=2&a=5'), qr/a,b,c/m, 'r.args sorted keys');
286
287 }
272 288
273 like(http_get('/var'), qr/variable=127.0.0.1/, 'r.variables'); 289 like(http_get('/var'), qr/variable=127.0.0.1/, 'r.variables');
274 like(http_get('/global'), qr/global=njs/, 'global code'); 290 like(http_get('/global'), qr/global=njs/, 'global code');
275 like(http_get('/log'), qr/200 OK/, 'r.log'); 291 like(http_get('/log'), qr/200 OK/, 'r.log');
276 292