From bc5938460492e2500ff6030c96621aede671d0ff Mon Sep 17 00:00:00 2001 From: Andrey Mikhaltsov Date: Fri, 30 Dec 2016 17:02:43 +0300 Subject: [PATCH] added test for map variables --- t/sanity.t | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/t/sanity.t b/t/sanity.t index ac43f4d..d0db074 100644 --- a/t/sanity.t +++ b/t/sanity.t @@ -647,3 +647,30 @@ GET /test nil --- no_error_log [error] + +=== TEST 19: upstream_name with valid explicit upstream set by variable +--- http_config + upstream some_upstream { + server 127.0.0.1:$TEST_NGINX_SERVER_PORT; + } + map $host $backend_http { + default "http"; + } +--- config + log_by_lua_block { + local upstream = require "ngx.upstream" + ngx.log(ngx.INFO, "upstream = " .. tostring(upstream.current_upstream_name())) + } + location /test { + proxy_pass $backend_http://some_upstream/back; + } + location /back { + echo ok; + } +--- request +GET /test +--- response_body +ok +--- log_level: info +--- error_log eval +qr/upstream = some_upstream/