Skip to content

Commit a70f549

Browse files
committed
fixed test 1 which was a false positive
1 parent 0b10554 commit a70f549

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

t/160-disable-init-by-lua.t

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ repeat_each(2);
55
plan tests => repeat_each() * (blocks() * 2);
66

77
$ENV{TEST_NGINX_HTML_DIR} ||= html_dir();
8+
89
my $html_dir = $ENV{TEST_NGINX_HTML_DIR};
910
my $http_config = <<_EOC_;
1011
init_by_lua_block {
@@ -15,16 +16,15 @@ my $http_config = <<_EOC_;
1516
}
1617
http {
1718
init_by_lua_block {
18-
-- if the code in the init_by_lua* is run, there
19-
-- will be a string contains the 'error'
2019
ngx.log(ngx.ERR, "run init_by_lua")
2120
}
2221
}
2322
]]
2423
2524
assert(os.execute("mkdir -p $html_dir/logs"))
25+
2626
local conf_file = "$html_dir/nginx.conf"
27-
local f, err = io.open(conf_file, 'w')
27+
local f, err = io.open(conf_file, "w")
2828
if not f then
2929
ngx.log(ngx.ERR, err)
3030
return
@@ -53,10 +53,9 @@ add_block_preprocessor(sub {
5353
if (!defined $block->request) {
5454
$block->set_value("request", "GET /t");
5555
}
56-
5756
});
5857

59-
log_level("debug");
58+
log_level("warn");
6059
no_long_string();
6160
run_tests();
6261

@@ -76,7 +75,7 @@ __DATA__
7675
return
7776
end
7877
79-
local out, err = p:read('*a')
78+
local out, err = p:read("*a")
8079
if not out then
8180
ngx.log(ngx.ERR, err)
8281
@@ -86,11 +85,11 @@ __DATA__
8685
}
8786
}
8887
--- no_error_log eval
89-
qr/\[error\] .+ (?!:nginx.pid" failed \(2: No such file or directory\))$/
88+
qr/\[error\] .*? init_by_lua:\d+: run init_by_lua/
9089
9190
9291
93-
=== TEST 2: ensure init_by_lua* is not run when testing Nginx configuration
92+
=== TEST 2: init_by_lua* does not run when testing Nginx configuration
9493
--- config
9594
location = /t {
9695
content_by_lua_block {
@@ -104,7 +103,7 @@ qr/\[error\] .+ (?!:nginx.pid" failed \(2: No such file or directory\))$/
104103
return
105104
end
106105
107-
local out, err = p:read('*a')
106+
local out, err = p:read("*a")
108107
if not out then
109108
ngx.log(ngx.ERR, err)
110109
@@ -119,7 +118,7 @@ qr/\[error\] .+ (?!:nginx.pid" failed \(2: No such file or directory\))$/
119118
return
120119
end
121120
122-
local out, err = p:read('*a')
121+
local out, err = p:read("*a")
123122
if not out then
124123
ngx.log(ngx.ERR, err)
125124
@@ -128,5 +127,5 @@ qr/\[error\] .+ (?!:nginx.pid" failed \(2: No such file or directory\))$/
128127
end
129128
}
130129
}
131-
--- no_error_log
132-
[error]
130+
--- no_error_log eval
131+
qr/\[error\] .*? init_by_lua:\d+: run init_by_lua/

0 commit comments

Comments
 (0)