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 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
# vim:set ft= ts=4 sw=4 et fdm=marker:
use Test::Nginx::Socket::Lua;
repeat_each(2);
plan tests => repeat_each() * (blocks() * 3);
our $HtmlDir = html_dir;
#$ENV{TEST_NGINX_MEMCACHED_PORT} ||= 11211;
no_long_string();
#no_diff();
#log_level 'warn';
run_tests();
__DATA__
=== TEST 1: receive
--- config
location /t {
content_by_lua '
local sock, err = ngx.req.socket()
sock.receive("l")
';
}
--- request
POST /t
--- more_headers: Content-Length: 1024
--- response_body_like: 500 Internal Server Error
--- error_code: 500
--- error_log
bad argument #1 to 'receive' (table expected, got string)
=== TEST 2: receiveuntil
--- config
location /t {
content_by_lua '
local sock, err = ngx.req.socket()
sock.receiveuntil(32, "ab")
';
}
--- request
POST /t
--- more_headers: Content-Length: 1024
--- response_body_like: 500 Internal Server Error
--- error_code: 500
--- error_log
bad argument #1 to 'receiveuntil' (table expected, got number)
=== TEST 3: send (bad arg number)
--- config
location /t {
content_by_lua '
local sock, err = ngx.socket.tcp()
sock.send("hello")
';
}
--- request
GET /t
--- response_body_like: 500 Internal Server Error
--- error_code: 500
--- error_log
expecting 2 arguments (including the object), but got 1
=== TEST 4: send (bad self)
--- config
location /t {
content_by_lua '
local sock, err = ngx.socket.tcp()
sock.send("hello", 32)
';
}
--- request
GET /t
--- response_body_like: 500 Internal Server Error
--- error_code: 500
--- error_log
bad argument #1 to 'send' (table expected, got string)
=== TEST 5: getreusedtimes (bad self)
--- config
location /t {
content_by_lua '
local sock, err = ngx.socket.tcp()
sock.getreusedtimes(2)
';
}
--- request
GET /t
--- response_body_like: 500 Internal Server Error
--- error_code: 500
--- error_log
bad argument #1 to 'getreusedtimes' (table expected, got number)
=== TEST 6: close (bad self)
--- config
location /t {
content_by_lua '
local sock, err = ngx.socket.tcp()
sock.close(2)
';
}
--- request
GET /t
--- response_body_like: 500 Internal Server Error
--- error_code: 500
--- error_log
bad argument #1 to 'close' (table expected, got number)
=== TEST 7: setkeepalive (bad self)
--- config
location /t {
content_by_lua '
local sock, err = ngx.socket.tcp()
sock.setkeepalive(2)
';
}
--- request
GET /t
--- response_body_like: 500 Internal Server Error
--- error_code: 500
--- error_log
bad argument #1 to 'setkeepalive' (table expected, got number)
|