Skip to content

Commit 1ceb716

Browse files
committed
tests: 161-load-resty-core.t: added a test asserting the directive honors 'lua_package_path'.
1 parent 3c5b22a commit 1ceb716

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

t/161-load-resty-core.t

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ repeat_each(2);
44

55
plan tests => repeat_each() * (blocks() * 3);
66

7+
our $HtmlDir = html_dir;
8+
79
add_block_preprocessor(sub {
810
my $block = shift;
911

@@ -59,7 +61,32 @@ resty.core loaded: true
5961
6062
6163
62-
=== TEST 4: lua_load_resty_core 'on' in stream block and 'off' in http block
64+
=== TEST 4: lua_load_resty_core honors the lua_package_path directive
65+
--- stream_config eval
66+
"lua_package_path '$::HtmlDir/?.lua;;';"
67+
--- stream_server_config
68+
content_by_lua_block {
69+
local loaded_resty_core = package.loaded["resty.core"]
70+
local resty_core = require "resty.core"
71+
72+
ngx.say("resty.core loaded: ", loaded_resty_core == resty_core)
73+
74+
resty_core.go()
75+
}
76+
--- stream_response
77+
resty.core loaded: true
78+
loaded from html dir
79+
--- user_files
80+
>>> resty/core.lua
81+
return {
82+
go = function ()
83+
ngx.say("loaded from html dir")
84+
end
85+
}
86+
87+
88+
89+
=== TEST 5: lua_load_resty_core 'on' in stream block and 'off' in http block
6390
--- http_config
6491
lua_load_resty_core off;
6592
--- config
@@ -128,7 +155,7 @@ resty.core loaded in http: false
128155
129156
130157
131-
=== TEST 5: lua_load_resty_core 'off' in stream block and 'on' in http block
158+
=== TEST 6: lua_load_resty_core 'off' in stream block and 'on' in http block
132159
--- config
133160
location = /t2 {
134161
content_by_lua_block {
@@ -197,7 +224,7 @@ resty.core loaded in http: true
197224
198225
199226
200-
=== TEST 6: lua_load_resty_core 'off' in stream block and 'off' in http block
227+
=== TEST 7: lua_load_resty_core 'off' in stream block and 'off' in http block
201228
--- http_config
202229
lua_load_resty_core off;
203230
--- config

0 commit comments

Comments
 (0)