Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added test for map variables #40

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions t/sanity.t
Original file line number Diff line number Diff line change
Expand Up @@ -647,3 +647,30 @@ GET /test
nil
--- no_error_log
[error]

=== TEST 19: upstream_name with valid explicit upstream set by variable
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point of this test case? Testing the standard map directive?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Point is to test situation where current_upstream_name() is called with block of upstream set by variable. For example, current_upstream_name() works fine in issue
#39 when scheme is explicitly set (location: /test). And returns error when scheme is set via variable (location: /test2).

--- 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/