Skip to content

Commit 4102b82

Browse files
committed
tests: 161-load-resty-core.t: added a test asserting the directive honors 'lua_package_path'.
1 parent 1882c30 commit 4102b82

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

t/161-load-resty-core.t

Lines changed: 29 additions & 0 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

@@ -66,3 +68,30 @@ resty.core loaded: false
6668
}
6769
--- response_body
6870
resty.core loaded: true
71+
72+
73+
74+
=== TEST 4: lua_load_resty_core honors the lua_package_path directive
75+
--- http_config eval
76+
"lua_package_path '$::HtmlDir/?.lua;;';"
77+
--- config
78+
location = /t {
79+
content_by_lua_block {
80+
local loaded_resty_core = package.loaded["resty.core"]
81+
local resty_core = require "resty.core"
82+
83+
ngx.say("resty.core loaded: ", loaded_resty_core == resty_core)
84+
85+
resty_core.go()
86+
}
87+
}
88+
--- response_body
89+
resty.core loaded: true
90+
loaded from html dir
91+
--- user_files
92+
>>> resty/core.lua
93+
return {
94+
go = function ()
95+
ngx.say("loaded from html dir")
96+
end
97+
}

0 commit comments

Comments
 (0)