# HG changeset patch # User Dmitry Volyntsev # Date 1661471595 25200 # Node ID e55aa7021ea538080698ac67fe9a2ef7d325d367 # Parent cadf15e2e2b39fb9a7b9dd9246f2513f819e5b77 Tests: added js r.internal test. diff --git a/js.t b/js.t --- a/js.t +++ b/js.t @@ -45,6 +45,7 @@ http { js_set $test_type test.type; js_set $test_global test.global_obj; js_set $test_log test.log; + js_set $test_internal test.sub_internal; js_set $test_except test.except; js_import test.js; @@ -118,6 +119,15 @@ http { return 200 $test_log; } + location /internal { + js_content test.internal; + } + + location /sub_internal { + internal; + return 200 $test_internal; + } + location /except { return 200 $test_except; } @@ -215,6 +225,16 @@ EOF r.log('SEE-LOG'); } + async function internal(r) { + let reply = await r.subrequest('/sub_internal'); + + r.return(200, `parent: \${r.internal} sub: \${reply.responseText}`); + } + + function sub_internal(r) { + return r.internal; + } + function except(r) { var fs = require('fs'); fs.readFileSync(); @@ -229,13 +249,13 @@ EOF } export default {njs:test_njs, method, version, addr, uri, - variable, global_obj, status, request_body, - request_body_cache, send, return_method, + variable, global_obj, status, request_body, internal, + request_body_cache, send, return_method, sub_internal, type, log, except, content_except, content_empty}; EOF -$t->try_run('no njs available')->plan(26); +$t->try_run('no njs available')->plan(27); ############################################################################### @@ -286,6 +306,14 @@ like(http_get('/var'), qr/variable=127.0 like(http_get('/global'), qr/global=njs/, 'global code'); like(http_get('/log'), qr/200 OK/, 'r.log'); +TODO: { +local $TODO = 'not yet' + unless http_get('/njs') =~ /^([.0-9]+)$/m && $1 ge '0.7.7'; + +like(http_get('/internal'), qr/parent: false sub: true/, 'r.internal'); + +} + http_get('/except'); http_get('/content_except');