1
1
# vim:set ft= ts=4 sw=4 et:
2
2
3
- use Test::Nginx::Socket::Lua;
4
- use Cwd qw( cwd) ;
3
+ use t::Test;
5
4
6
5
repeat_each(2 );
7
6
8
7
plan tests => repeat_each() * (3 * blocks());
9
8
10
- my $pwd = cwd();
11
-
12
- our $HttpConfig = qq{
13
- resolver \$ TEST_NGINX_RESOLVER;
14
- lua_package_path "$pwd /lib/?.lua;$pwd /t/lib/?.lua;$pwd /../lua-resty-rsa/lib/?.lua;$pwd /../lua-resty-string/lib/?.lua;;";
15
- lua_package_cpath "/usr/local/openresty-debug/lualib/?.so;/usr/local/openresty/lualib/?.so;;";
16
- } ;
17
-
18
- $ENV {TEST_NGINX_RESOLVER } = ' 8.8.8.8' ;
19
- $ENV {TEST_NGINX_MYSQL_PORT } ||= 3306;
20
- $ENV {TEST_NGINX_MYSQL_HOST } ||= ' 127.0.0.1' ;
21
- $ENV {TEST_NGINX_MYSQL_PATH } ||= ' /var/run/mysql/mysql.sock' ;
22
-
23
9
# log_level 'warn';
24
10
25
11
# no_long_string();
@@ -31,9 +17,7 @@ run_tests();
31
17
__DATA__
32
18
33
19
=== TEST 1 : connect db using charset option (utf8 )
34
- --- http_config eval: $::HttpConfig
35
- --- config
36
- location /t {
20
+ -- - server_config
37
21
content_by_lua_block {
38
22
local ljson = require " ljson"
39
23
local mysql = require " resty.mysql"
@@ -84,9 +68,6 @@ __DATA__
84
68
85
69
ngx. say (ljson. encode(res))
86
70
}
87
- }
88
- --- request
89
- GET /t
90
71
-- - response_body
91
72
[{" id" : " 1" ," name" : " 愛麗絲" }]
92
73
-- - no_error_log
95
76
96
77
97
78
=== TEST 2 : connect db using charset option (big5)
98
- --- http_config eval: $::HttpConfig
99
- --- config
100
- location /t {
79
+ -- - server_config
101
80
content_by_lua_block {
102
81
local ljson = require " ljson"
103
82
local mysql = require " resty.mysql"
@@ -148,9 +127,6 @@ GET /t
148
127
149
128
ngx. say (ljson. encode(res))
150
129
}
151
- }
152
- --- request
153
- GET /t
154
130
-- - response_body eval
155
131
qq / [{ " id" : " 1" ," name" : " \x{ b7} R\x{ c4} R\x{ b5} \x{ b7} " } ]\n /
156
132
-- - no_error_log
@@ -159,9 +135,7 @@ qq/[{"id":"1","name":"\x{b7}R\x{c4}R\x{b5}\x{b7}"}]\n/
159
135
160
136
161
137
=== TEST 3 : connect db using charset option (gbk)
162
- --- http_config eval: $::HttpConfig
163
- --- config
164
- location /t {
138
+ -- - server_config
165
139
content_by_lua_block {
166
140
local ljson = require " ljson"
167
141
local mysql = require " resty.mysql"
@@ -212,9 +186,6 @@ qq/[{"id":"1","name":"\x{b7}R\x{c4}R\x{b5}\x{b7}"}]\n/
212
186
213
187
ngx. say (ljson. encode(res))
214
188
}
215
- }
216
- --- request
217
- GET /t
218
189
-- - response_body eval
219
190
qq / [{ " id" : " 1" ," name" : " \x{ 90 } \x{ db} \x{ fb} \x{ 90 } \x{ bd} z" } ]\n /
220
191
-- - no_error_log
0 commit comments