Skip to content

Commit 3740962

Browse files
committed
added tests for the new lua_use_default_type directive.
1 parent e5d47c4 commit 3740962

File tree

1 file changed

+122
-0
lines changed

1 file changed

+122
-0
lines changed

t/118-use-default-type.t

+122
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# vim:set ft= ts=4 sw=4 et fdm=marker:
2+
3+
use lib 'lib';
4+
use t::TestNginxLua;
5+
6+
repeat_each(2);
7+
8+
plan tests => repeat_each() * (blocks() * 4);
9+
10+
our $HtmlDir = html_dir;
11+
12+
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211;
13+
$ENV{TEST_NGINX_RESOLVER} ||= '8.8.8.8';
14+
15+
#log_level 'warn';
16+
log_level 'debug';
17+
18+
#no_long_string();
19+
#no_diff();
20+
run_tests();
21+
22+
__DATA__
23+
24+
=== TEST 1: lua_use_default_type default on
25+
--- config
26+
location /lua {
27+
default_type text/plain;
28+
content_by_lua '
29+
ngx.say("hello")
30+
';
31+
}
32+
--- request
33+
GET /lua
34+
--- response_body
35+
hello
36+
--- response_headers
37+
Content-Type: text/plain
38+
--- no_error_log
39+
[error]
40+
41+
42+
43+
=== TEST 2: lua_use_default_type explicitly on
44+
--- config
45+
lua_use_default_type on;
46+
location /lua {
47+
default_type text/plain;
48+
content_by_lua '
49+
ngx.say("hello")
50+
';
51+
}
52+
--- request
53+
GET /lua
54+
--- response_body
55+
hello
56+
--- response_headers
57+
Content-Type: text/plain
58+
--- no_error_log
59+
[error]
60+
61+
62+
63+
=== TEST 3: lua_use_default_type off
64+
--- config
65+
lua_use_default_type off;
66+
location /lua {
67+
default_type text/plain;
68+
content_by_lua '
69+
ngx.say("hello")
70+
';
71+
}
72+
--- request
73+
GET /lua
74+
--- response_body
75+
hello
76+
--- response_headers
77+
!Content-Type
78+
--- no_error_log
79+
[error]
80+
81+
82+
83+
=== TEST 4: overriding lua_use_default_type off
84+
--- config
85+
lua_use_default_type off;
86+
location /lua {
87+
lua_use_default_type on;
88+
default_type text/plain;
89+
content_by_lua '
90+
ngx.say("hello")
91+
';
92+
}
93+
--- request
94+
GET /lua
95+
--- response_body
96+
hello
97+
--- response_headers
98+
Content-Type: text/plain
99+
--- no_error_log
100+
[error]
101+
102+
103+
104+
=== TEST 5: overriding lua_use_default_type on
105+
--- config
106+
lua_use_default_type on;
107+
location /lua {
108+
lua_use_default_type off;
109+
default_type text/plain;
110+
content_by_lua '
111+
ngx.say("hello")
112+
';
113+
}
114+
--- request
115+
GET /lua
116+
--- response_body
117+
hello
118+
--- response_headers
119+
!Content-Type
120+
--- no_error_log
121+
[error]
122+

0 commit comments

Comments
 (0)