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

resty-ctx.t conversion to APIcast::Blackbox #1424

Merged
Merged
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
51 changes: 34 additions & 17 deletions t/resty-ctx.t
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
use lib 't';
use Test::APIcast 'no_plan';
use Test::APIcast::Blackbox 'no_plan';

repeat_each(1);
run_tests();

__DATA__

=== TEST 1: get context reference
get context reference number
--- http_config
lua_package_path "$TEST_NGINX_LUA_PATH";
--- config
location = /t {
content_by_lua_block {
ngx.say(require('resty.ctx').ref())
}
--- configuration
{}
--- upstream
location = /t {
content_by_lua_block {
ngx.say(require('resty.ctx').ref())
}
}
--- upstream_name
ctx
--- more_headers
Host: ctx
--- request
GET /t
--- response_body
Expand All @@ -25,9 +30,9 @@ GET /t


=== TEST 2: stash context reference
--- http_config
lua_package_path "$TEST_NGINX_LUA_PATH";
--- config
--- configuration
{}
--- upstream
set $ctx_ref -1;

location = /t {
Expand All @@ -39,6 +44,10 @@ GET /t
ngx.say(ngx.var.ctx_ref)
}
}
--- upstream_name
ctx
--- more_headers
Host: ctx
--- request
GET /t
--- response_body
Expand All @@ -49,9 +58,9 @@ GET /t


=== TEST 3: apply context reference
--- http_config
lua_package_path "$TEST_NGINX_LUA_PATH";
--- config
--- configuration
{}
--- upstream
set $ctx_ref -1;

location = /t {
Expand All @@ -73,6 +82,10 @@ GET /t
ngx.say(ngx.ctx.foo)
}
}
--- upstream_name
ctx
--- more_headers
Host: ctx
--- request
GET /t
--- response_body
Expand All @@ -83,9 +96,9 @@ bar


=== TEST 4: context is not garbage collected
--- http_config
lua_package_path "$TEST_NGINX_LUA_PATH";
--- config
--- configuration
{}
--- upstream
set $ctx_ref -1;

location = /t {
Expand Down Expand Up @@ -126,6 +139,10 @@ bar
ngx.say(ngx.ctx.foo)
}
}
--- upstream_name
ctx
--- more_headers
Host: ctx
--- request
GET /t
--- response_body
Expand Down
Loading