File tree Expand file tree Collapse file tree 1 file changed +34
-17
lines changed Expand file tree Collapse file tree 1 file changed +34
-17
lines changed Original file line number Diff line number Diff line change 11use lib ' t' ;
2- use Test::APIcast ' no_plan' ;
2+ use Test::APIcast::Blackbox ' no_plan' ;
33
4+ repeat_each(1);
45run_tests();
56
67__DATA__
78
89=== TEST 1: get context reference
910get context reference number
10- --- http_config
11- lua_package_path "$TEST_NGINX_LUA_PATH";
12- --- config
13- location = /t {
14- content_by_lua_block {
15- ngx.say(require('resty.ctx').ref())
16- }
11+ --- configuration
12+ {}
13+ --- upstream
14+ location = /t {
15+ content_by_lua_block {
16+ ngx.say(require('resty.ctx').ref())
1717 }
18+ }
19+ --- upstream_name
20+ ctx
21+ --- more_headers
22+ Host: ctx
1823--- request
1924GET /t
2025--- response_body
2530
2631
2732=== TEST 2: stash context reference
28- --- http_config
29- lua_package_path "$TEST_NGINX_LUA_PATH";
30- --- config
33+ --- configuration
34+ {}
35+ --- upstream
3136 set $ctx_ref -1;
3237
3338 location = /t {
@@ -39,6 +44,10 @@ GET /t
3944 ngx.say(ngx.var.ctx_ref)
4045 }
4146 }
47+ --- upstream_name
48+ ctx
49+ --- more_headers
50+ Host: ctx
4251--- request
4352GET /t
4453--- response_body
4958
5059
5160=== TEST 3: apply context reference
52- --- http_config
53- lua_package_path "$TEST_NGINX_LUA_PATH";
54- --- config
61+ --- configuration
62+ {}
63+ --- upstream
5564 set $ctx_ref -1;
5665
5766 location = /t {
@@ -73,6 +82,10 @@ GET /t
7382 ngx.say(ngx.ctx.foo)
7483 }
7584 }
85+ --- upstream_name
86+ ctx
87+ --- more_headers
88+ Host: ctx
7689--- request
7790GET /t
7891--- response_body
8396
8497
8598=== TEST 4: context is not garbage collected
86- --- http_config
87- lua_package_path "$TEST_NGINX_LUA_PATH";
88- --- config
99+ --- configuration
100+ {}
101+ --- upstream
89102 set $ctx_ref -1;
90103
91104 location = /t {
126139 ngx.say(ngx.ctx.foo)
127140 }
128141 }
142+ --- upstream_name
143+ ctx
144+ --- more_headers
145+ Host: ctx
129146--- request
130147GET /t
131148--- response_body
You can’t perform that action at this time.
0 commit comments