/
014-bugs.t
114 lines (93 loc) · 2.49 KB
/
014-bugs.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# vim:set ft= ts=4 sw=4 et fdm=marker:
use lib 'lib';
use Test::Nginx::Socket;
#worker_connections(1014);
#master_process_enabled(1);
#log_level('warn');
#repeat_each(120);
repeat_each(1);
plan tests => blocks() * repeat_each() * 2;
our $HtmlDir = html_dir;
#warn $html_dir;
#$ENV{LUA_PATH} = "$html_dir/?.lua";
#no_diff();
#no_long_string();
$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211;
run_tests();
__DATA__
=== TEST 1: sanity
--- http_config eval
"lua_package_path '$::HtmlDir/?.lua;./?.lua';"
--- config
location /load {
content_by_lua '
package.loaded.foo = nil;
local foo = require "foo";
foo.hi()
';
}
--- request
GET /load
--- user_files
>>> foo.lua
module(..., package.seeall);
function foo ()
return 1
return 2
end
--- error_code: 500
--- response_body_like: 500 Internal Server Error
=== TEST 2: sanity
--- http_config
lua_package_path '/home/agentz/rpm/BUILD/lua-yajl-1.1/build/?.so;/home/lz/luax/?.so;./?.so';
--- config
location = '/report/listBidwordPrices4lzExtra.htm' {
content_by_lua '
local yajl = require "yajl"
local w = ngx.var.arg_words
w = ngx.unescape_uri(w)
local r = {}
print("start for")
for id in string.gmatch(w, "%d+") do
r[id] = -1
end
print("end for, start yajl")
ngx.print(yajl.to_string(r))
print("end yajl")
';
}
--- request
GET /report/listBidwordPrices4lzExtra.htm?words=123,156,2532
--- response_body
--- SKIP
=== TEST 3: sanity
I dunno why this test is not passing. TODO'ing...
--- config
location = /memc {
#set $memc_value 'hello';
set $memc_value $arg_v;
set $memc_cmd $arg_c;
set $memc_key $arg_k;
#set $memc_value hello;
memc_pass 127.0.0.1:$TEST_NGINX_MEMCACHED_PORT;
#echo $memc_value;
}
location = /echo {
echo_location '/memc?c=get&k=foo';
echo_location '/memc?c=set&k=foo&v=hello';
echo_location '/memc?c=get&k=foo';
}
location = /main {
content_by_lua '
res = ngx.location.capture("/memc?c=get&k=foo&v=")
ngx.say("1: ", res.body)
res = ngx.location.capture("/memc?c=set&k=foo&v=bar");
ngx.say("2: ", res.body);
res = ngx.location.capture("/memc?c=get&k=foo")
ngx.say("3: ", res.body);
';
}
--- request
GET /main
--- response_body_like: 3: bar$
--- SKIP