@@ -13,6 +13,7 @@ init_by_lua_block {
1313
1414$ ENV {TEST_NGINX_RESOLVER} = ' 8.8.8.8' ;
1515$ ENV {TEST_NGINX_REDIS_PORT} ||= 6379 ;
16+ $ ENV {TEST_NGINX_REDIS_SOCKET} ||= ' unix://tmp/redis/redis.sock' ;
1617
1718no_long_string();
1819run_tests();
@@ -213,14 +214,14 @@ GET /t
213214ERR Client sent AUTH, but no password is set
214215
215216
216- === TEST 7 : unix domain socket
217+ === TEST 7 : Bad unix domain socket path should fail
217218-- - http_config eval: $::HttpConfig
218219-- - config
219220location / t {
220221 lua_socket_log_errors Off;
221222 content_by_lua_block {
222223 local redis, err = require (" resty.redis.connector" ). new ({
223- path = " unix://tmp/redis.sock " ,
224+ path = " unix://GARBAGE_PATH_AKFDKAJSFKJSAFLKJSADFLKJSANCKAJSNCKJSANCLKAJS " ,
224225 }): connect()
225226
226227 assert(not redis and err == " no such file or directory" ,
@@ -233,6 +234,30 @@ GET /t
233234[error]
234235
235236
237+ === TEST 7.1 : Good unix domain socket path should succeed
238+ -- - http_config eval: $::HttpConfig
239+ -- - config
240+ location / t {
241+ lua_socket_log_errors Off;
242+ content_by_lua_block {
243+ ngx. log (ngx. DEBUG, " $ TEST_NGINX_REDIS_SOCKET" )
244+ local redis, err = require (" resty.redis.connector" ). new ({
245+ path = " $ TEST_NGINX_REDIS_SOCKET" ,
246+ }): connect()
247+
248+ assert (redis and not err,
249+ " connection should be valid" )
250+
251+
252+ redis: close()
253+ }
254+ }
255+ -- - request
256+ GET / t
257+ -- - no_error_log
258+ [error]
259+
260+
236261=== TEST 8 : parse_dsn
237262-- - http_config eval: $::HttpConfig
238263-- - config
0 commit comments