comparison js_subrequests.t @ 1557:b194552fcc21

Tests: adapted js_subrequests.t to njs changes after 0.4.0. Since 0.4.0, external objects support implicit convertion to string. To cope with that, they are replaced with a symbol value which does not support implicit conversion to string.
author Dmitry Volyntsev <xeioex@nginx.com>
date Wed, 18 Mar 2020 17:44:37 +0300
parents cae83c98654a
children 726877fc4b08
comparison
equal deleted inserted replaced
1556:3ff92feb99d1 1557:b194552fcc21
305 body_fwd_cb); 305 body_fwd_cb);
306 } 306 }
307 307
308 function sr_options_method_head(r) { 308 function sr_options_method_head(r) {
309 r.subrequest('/p/method', {method:'HEAD'}, reply => { 309 r.subrequest('/p/method', {method:'HEAD'}, reply => {
310 r.return(200, JSON.stringify({c:reply.status, 310 r.return(200, JSON.stringify({c:reply.status}));
311 s:reply.responseBody.length}));
312 }); 311 });
313 } 312 }
314 313
315 function sr_body(r) { 314 function sr_body(r) {
316 r.subrequest('/p/sub1', body_fwd_cb); 315 r.subrequest('/p/sub1', body_fwd_cb);
460 function sr_except_not_a_func(r) { 459 function sr_except_not_a_func(r) {
461 r.subrequest('/sub1', 'a=1', 'b'); 460 r.subrequest('/sub1', 'a=1', 'b');
462 } 461 }
463 462
464 function sr_except_failed_to_convert_arg(r) { 463 function sr_except_failed_to_convert_arg(r) {
465 r.subrequest('/sub1', r.args, ()=>{}); 464 r.subrequest('/sub1', Symbol.toStringTag, ()=>{});
466 } 465 }
467 466
468 function sr_except_failed_to_convert_options_arg(r) { 467 function sr_except_failed_to_convert_options_arg(r) {
469 r.subrequest('/sub1', {args:r.args}, ()=>{}); 468 r.subrequest('/sub1', {args:r.args}, ()=>{});
470 } 469 }
471 470
472 function sr_uri_except(r) { 471 function sr_uri_except(r) {
473 r.subrequest(r, 'a=1', 'b'); 472 r.subrequest(Symbol.toStringTag, 'a=1', 'b');
474 } 473 }
475 474
476 function body_fwd_cb(r) { 475 function body_fwd_cb(r) {
477 r.parent.return(200, JSON.stringify(JSON.parse(r.responseBody))); 476 r.parent.return(200, JSON.stringify(JSON.parse(r.responseBody)));
478 } 477 }
494 is(get_json('/sr_args'), '{"h":"xxx"}', 'sr_args'); 493 is(get_json('/sr_args'), '{"h":"xxx"}', 'sr_args');
495 is(get_json('/sr_options_args'), '{"h":"xxx"}', 'sr_options_args'); 494 is(get_json('/sr_options_args'), '{"h":"xxx"}', 'sr_options_args');
496 is(get_json('/sr_options_method?m=POST'), '["POST"]', 'sr method POST'); 495 is(get_json('/sr_options_method?m=POST'), '["POST"]', 'sr method POST');
497 is(get_json('/sr_options_method?m=PURGE'), '["PURGE"]', 'sr method PURGE'); 496 is(get_json('/sr_options_method?m=PURGE'), '["PURGE"]', 'sr method PURGE');
498 is(get_json('/sr_options_body'), '["REQ-BODY"]', 'sr_options_body'); 497 is(get_json('/sr_options_body'), '["REQ-BODY"]', 'sr_options_body');
499 is(get_json('/sr_options_method_head'), '{"c":200,"s":0}', 498 is(get_json('/sr_options_method_head'), '{"c":200}', 'sr_options_method_head');
500 'sr_options_method_head');
501 is(get_json('/sr_body'), '{"a":{"b":1}}', 'sr_body'); 499 is(get_json('/sr_body'), '{"a":{"b":1}}', 'sr_body');
502 is(get_json('/sr_body_special'), '{"e":"msg"}', 'sr_body_special'); 500 is(get_json('/sr_body_special'), '{"e":"msg"}', 'sr_body_special');
503 is(get_json('/sr_in_variable_handler'), '["CB-VAR"]', 'sr_in_variable_handler'); 501 is(get_json('/sr_in_variable_handler'), '["CB-VAR"]', 'sr_in_variable_handler');
504 502
505 $t->todo_alerts() if $t->read_file('nginx.conf') =~ /aio (on|threads)/ 503 $t->todo_alerts() if $t->read_file('nginx.conf') =~ /aio (on|threads)/