Mercurial > hg > nginx-tests
comparison js.t @ 1310:3882f8f3b2bc
Tests: added njs extended logging tests.
author | Dmitry Volyntsev <xeioex@nginx.com> |
---|---|
date | Thu, 29 Mar 2018 17:01:31 +0300 |
parents | edf5a3c9e36a |
children | 890516ca898a |
comparison
equal
deleted
inserted
replaced
1309:3eb1de7e3b41 | 1310:3882f8f3b2bc |
---|---|
176 function test_var(req, res) { | 176 function test_var(req, res) { |
177 return 'variable=' + req.variables.remote_addr; | 177 return 'variable=' + req.variables.remote_addr; |
178 } | 178 } |
179 | 179 |
180 function test_log(req, res) { | 180 function test_log(req, res) { |
181 req.log("SEE-THIS"); | 181 req.log("SEE-THIS-LOG"); |
182 req.warn("SEE-THIS-WARN"); | |
183 req.error("SEE-THIS-ERROR"); | |
182 } | 184 } |
183 | 185 |
184 function test_except(req, res) { | 186 function test_except(req, res) { |
185 var fs = require('fs'); | 187 var fs = require('fs'); |
186 fs.readFileSync(); | 188 fs.readFileSync(); |
259 JSON.parse({}.a.a); | 261 JSON.parse({}.a.a); |
260 } | 262 } |
261 | 263 |
262 EOF | 264 EOF |
263 | 265 |
264 $t->try_run('no njs available')->plan(22); | 266 $t->try_run('no njs available')->plan(24); |
265 | 267 |
266 ############################################################################### | 268 ############################################################################### |
267 | 269 |
268 like(http_get('/req_method'), qr/method=GET/, 'req.method'); | 270 like(http_get('/req_method'), qr/method=GET/, 'req.method'); |
269 like(http_get('/req_version'), qr/version=1.0/, 'req.httpVersion'); | 271 like(http_get('/req_version'), qr/version=1.0/, 'req.httpVersion'); |
300 | 302 |
301 } | 303 } |
302 | 304 |
303 $t->stop(); | 305 $t->stop(); |
304 | 306 |
305 ok(index($t->read_file('error.log'), 'SEE-THIS') > 0, 'log js'); | 307 ok(index($t->read_file('error.log'), 'SEE-THIS-LOG') > 0, 'log js'); |
308 ok(index($t->read_file('error.log'), 'SEE-THIS-WARN') > 0, 'warn js'); | |
309 ok(index($t->read_file('error.log'), 'SEE-THIS-ERROR') > 0, 'error js'); | |
306 ok(index($t->read_file('error.log'), 'at fs.readFileSync') > 0, | 310 ok(index($t->read_file('error.log'), 'at fs.readFileSync') > 0, |
307 'js_set backtrace'); | 311 'js_set backtrace'); |
308 ok(index($t->read_file('error.log'), 'at JSON.parse') > 0, | 312 ok(index($t->read_file('error.log'), 'at JSON.parse') > 0, |
309 'js_content backtrace'); | 313 'js_content backtrace'); |
310 | 314 |