Skip to content

Commit b18966e

Browse files
committed
tests: added a passing test for the connection refused error case (#106).
1 parent bd06e72 commit b18966e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

t/sanity.t

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -827,3 +827,34 @@ a_dog: an animal
827827
a_dog: an animal
828828
--- no_error_log
829829
[error]
830+
831+
832+
833+
=== TEST 15: connection refused
834+
--- http_config eval: $::HttpConfig
835+
--- config
836+
location /t {
837+
content_by_lua '
838+
local redis = require "resty.redis"
839+
local red = redis:new()
840+
841+
red:set_timeout(10000) -- 10 sec
842+
843+
local ok, err = red:connect("127.0.0.1", 81)
844+
if not ok then
845+
ngx.say("failed to connect: ", err)
846+
return
847+
end
848+
849+
ngx.say("connected")
850+
851+
red:close()
852+
';
853+
}
854+
--- request
855+
GET /t
856+
--- response_body
857+
failed to connect: connection refused
858+
--- timeout: 3
859+
--- no_error_log
860+
[alert]

0 commit comments

Comments
 (0)