comparison js.t @ 1331:f48d2792730e

Tests: added njs empty js_content handler test.
author Dmitry Volyntsev <xeioex@nginx.com>
date Fri, 01 Jun 2018 16:03:19 +0300
parents 890516ca898a
children 746d9ffdbd26
comparison
equal deleted inserted replaced
1330:b82ed2061f65 1331:f48d2792730e
94 94
95 location /req_except { 95 location /req_except {
96 return 200 $test_except; 96 return 200 $test_except;
97 } 97 }
98 98
99 location /req_empty {
100 js_content content_empty;
101 }
102
99 location /res_status { 103 location /res_status {
100 js_content status; 104 js_content status;
101 } 105 }
102 106
103 location /res_ctype { 107 location /res_ctype {
257 261
258 function content_except(req, res) { 262 function content_except(req, res) {
259 JSON.parse({}.a.a); 263 JSON.parse({}.a.a);
260 } 264 }
261 265
266 function content_empty(req, res) {
267 }
268
262 EOF 269 EOF
263 270
264 $t->try_run('no njs available')->plan(22); 271 $t->try_run('no njs available')->plan(23);
265 272
266 ############################################################################### 273 ###############################################################################
267 274
268 like(http_get('/req_method'), qr/method=GET/, 'req.method'); 275 like(http_get('/req_method'), qr/method=GET/, 'req.method');
269 like(http_get('/req_version'), qr/version=1.0/, 'req.httpVersion'); 276 like(http_get('/req_version'), qr/version=1.0/, 'req.httpVersion');
274 like(http_get('/req_arg?foO=12345'), qr/arg=12345/, 'req.args'); 281 like(http_get('/req_arg?foO=12345'), qr/arg=12345/, 'req.args');
275 like(http_get('/req_iarg?foo=12345&foo2=bar&nn=22&foo-3=z'), qr/12345barz/, 282 like(http_get('/req_iarg?foo=12345&foo2=bar&nn=22&foo-3=z'), qr/12345barz/,
276 'req.args iteration'); 283 'req.args iteration');
277 like(http_get('/req_var'), qr/variable=127.0.0.1/, 'req.variables'); 284 like(http_get('/req_var'), qr/variable=127.0.0.1/, 'req.variables');
278 like(http_get('/req_log'), qr/200 OK/, 'req.log'); 285 like(http_get('/req_log'), qr/200 OK/, 'req.log');
286 like(http_get('/req_empty'), qr/500 Internal Server Error/, 'empty handler');
279 287
280 like(http_get('/res_status'), qr/204 No Content/, 'res.status'); 288 like(http_get('/res_status'), qr/204 No Content/, 'res.status');
281 like(http_get('/res_ctype'), qr/Content-Type: application\/foo/, 289 like(http_get('/res_ctype'), qr/Content-Type: application\/foo/,
282 'res.contentType'); 290 'res.contentType');
283 like(http_get('/res_clen'), qr/Content-Length: 5/, 'res.contentLength'); 291 like(http_get('/res_clen'), qr/Content-Length: 5/, 'res.contentLength');