Skip to content

Commit d27d3ba

Browse files
committed
added a test case for setting and getting an entry with the empty string value. thanks huang kun.
1 parent 85ada61 commit d27d3ba

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

t/bugs.t

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,3 +147,60 @@ Not found, dear...
147147
--- no_error_log
148148
[error]
149149

150+
151+
152+
=== TEST 3: set and get an empty string
153+
--- http_config eval: $::HttpConfig
154+
--- config
155+
location /t {
156+
content_by_lua '
157+
local redis = require "resty.redis"
158+
local red = redis:new()
159+
160+
red:set_timeout(1000) -- 1 sec
161+
162+
-- or connect to a unix domain socket file listened
163+
-- by a redis server:
164+
-- local ok, err = red:connect("unix:/path/to/redis.sock")
165+
166+
local ok, err = red:connect("127.0.0.1", $TEST_NGINX_REDIS_PORT)
167+
if not ok then
168+
ngx.say("failed to connect: ", err)
169+
return
170+
end
171+
172+
res, err = red:set("dog", "")
173+
if not res then
174+
ngx.say("failed to set dog: ", err)
175+
return
176+
end
177+
178+
ngx.say("set dog: ", res)
179+
180+
for i = 1, 2 do
181+
local res, err = red:get("dog")
182+
if err then
183+
ngx.say("failed to get dog: ", err)
184+
return
185+
end
186+
187+
if not res then
188+
ngx.say("dog not found.")
189+
return
190+
end
191+
192+
ngx.say("dog: ", res)
193+
end
194+
195+
red:close()
196+
';
197+
}
198+
--- request
199+
GET /t
200+
--- response_body
201+
set dog: OK
202+
dog:
203+
dog:
204+
--- no_error_log
205+
[error]
206+

0 commit comments

Comments
 (0)