comparison js_subrequests.t @ 1567:726877fc4b08

Tests: fixed js_subrequest.t compatibility to 0.3.7. This fixes b194552fcc21 since Symbol type was introduced in 0.3.8.
author Dmitry Volyntsev <xeioex@nginx.com>
date Wed, 06 May 2020 12:08:07 +0000
parents b194552fcc21
children bc0990ea2e5b
comparison
equal deleted inserted replaced
1566:5cf2f4da8bd5 1567:726877fc4b08
158 158
159 location /sr_except_not_a_func { 159 location /sr_except_not_a_func {
160 js_content sr_except_not_a_func; 160 js_content sr_except_not_a_func;
161 } 161 }
162 162
163 location /sr_except_failed_to_convert_arg {
164 js_content sr_except_failed_to_convert_arg;
165 }
166
167 location /sr_except_failed_to_convert_options_arg { 163 location /sr_except_failed_to_convert_options_arg {
168 js_content sr_except_failed_to_convert_options_arg; 164 js_content sr_except_failed_to_convert_options_arg;
169 } 165 }
170 166
171 location /sr_except_invalid_options_header_only { 167 location /sr_except_invalid_options_header_only {
259 } 255 }
260 256
261 EOF 257 EOF
262 258
263 $t->write_file('test.js', <<EOF); 259 $t->write_file('test.js', <<EOF);
260 this.Failed = {get toConvert() { return {toString(){return {};}}}};
261
264 function test_njs(r) { 262 function test_njs(r) {
265 r.return(200, njs.version); 263 r.return(200, njs.version);
266 } 264 }
267 265
268 function sr(r) { 266 function sr(r) {
458 456
459 function sr_except_not_a_func(r) { 457 function sr_except_not_a_func(r) {
460 r.subrequest('/sub1', 'a=1', 'b'); 458 r.subrequest('/sub1', 'a=1', 'b');
461 } 459 }
462 460
463 function sr_except_failed_to_convert_arg(r) {
464 r.subrequest('/sub1', Symbol.toStringTag, ()=>{});
465 }
466
467 function sr_except_failed_to_convert_options_arg(r) { 461 function sr_except_failed_to_convert_options_arg(r) {
468 r.subrequest('/sub1', {args:r.args}, ()=>{}); 462 r.subrequest('/sub1', {args:Failed.toConvert}, ()=>{});
469 } 463 }
470 464
471 function sr_uri_except(r) { 465 function sr_uri_except(r) {
472 r.subrequest(Symbol.toStringTag, 'a=1', 'b'); 466 r.subrequest(Failed.toConvert, 'a=1', 'b');
473 } 467 }
474 468
475 function body_fwd_cb(r) { 469 function body_fwd_cb(r) {
476 r.parent.return(200, JSON.stringify(JSON.parse(r.responseBody))); 470 r.parent.return(200, JSON.stringify(JSON.parse(r.responseBody)));
477 } 471 }
552 http_get('/sr_in_sr'); 546 http_get('/sr_in_sr');
553 http_get('/sr_in_variable_handler'); 547 http_get('/sr_in_variable_handler');
554 http_get('/sr_error_page'); 548 http_get('/sr_error_page');
555 http_get('/sr_too_large'); 549 http_get('/sr_too_large');
556 http_get('/sr_except_not_a_func'); 550 http_get('/sr_except_not_a_func');
557 http_get('/sr_except_failed_to_convert_arg');
558 http_get('/sr_except_failed_to_convert_options_arg'); 551 http_get('/sr_except_failed_to_convert_options_arg');
559 http_get('/sr_uri_except'); 552 http_get('/sr_uri_except');
560 553
561 is(get_json('/sr_in_sr_callback'), 554 is(get_json('/sr_in_sr_callback'),
562 '{"e":"subrequest can only be created for the primary request"}', 555 '{"e":"subrequest can only be created for the primary request"}',
566 559
567 ok(index($t->read_file('error.log'), 'callback is not a function') > 0, 560 ok(index($t->read_file('error.log'), 'callback is not a function') > 0,
568 'subrequest cb exception'); 561 'subrequest cb exception');
569 ok(index($t->read_file('error.log'), 'failed to convert uri arg') > 0, 562 ok(index($t->read_file('error.log'), 'failed to convert uri arg') > 0,
570 'subrequest uri exception'); 563 'subrequest uri exception');
571 ok(index($t->read_file('error.log'), 'failed to convert args') > 0, 564 ok(index($t->read_file('error.log'), 'failed to convert options.args') > 0,
572 'subrequest invalid args exception'); 565 'subrequest invalid args exception');
573 ok(index($t->read_file('error.log'), 'too big subrequest response') > 0, 566 ok(index($t->read_file('error.log'), 'too big subrequest response') > 0,
574 'subrequest too large body'); 567 'subrequest too large body');
575 ok(index($t->read_file('error.log'), 'subrequest creation failed') > 0, 568 ok(index($t->read_file('error.log'), 'subrequest creation failed') > 0,
576 'subrequest creation failed'); 569 'subrequest creation failed');