File tree Expand file tree Collapse file tree 4 files changed +17
-10
lines changed Expand file tree Collapse file tree 4 files changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -124,10 +124,17 @@ def ssl_context
124
124
125
125
def server_url
126
126
if path
127
- "#{ path } /#{ db } "
127
+ url = "unix://#{ path } "
128
+ if db != 0
129
+ url = "#{ url } ?db=#{ db } "
130
+ end
128
131
else
129
- "redis#{ 's' if ssl? } ://#{ host } :#{ port } /#{ db } "
132
+ url = "redis#{ 's' if ssl? } ://#{ host } :#{ port } "
133
+ if db != 0
134
+ url = "#{ url } /#{ db } "
135
+ end
130
136
end
137
+ url
131
138
end
132
139
133
140
private
Original file line number Diff line number Diff line change @@ -198,13 +198,13 @@ def test_overriding
198
198
end
199
199
200
200
def test_server_url
201
- assert_equal "redis://localhost:6379/0 " , Config . new . server_url
202
- assert_equal "redis://localhost:6379/0 " , Config . new ( username : "george" , password : "hunter2" ) . server_url
201
+ assert_equal "redis://localhost:6379" , Config . new . server_url
202
+ assert_equal "redis://localhost:6379" , Config . new ( username : "george" , password : "hunter2" ) . server_url
203
203
assert_equal "redis://localhost:6379/5" , Config . new ( db : 5 ) . server_url
204
- assert_equal "redis://example.com:8080/0 " , Config . new ( host : "example.com" , port : 8080 ) . server_url
205
- assert_equal "rediss://localhost:6379/0 " , Config . new ( ssl : true ) . server_url
204
+ assert_equal "redis://example.com:8080" , Config . new ( host : "example.com" , port : 8080 ) . server_url
205
+ assert_equal "rediss://localhost:6379" , Config . new ( ssl : true ) . server_url
206
206
207
- assert_equal "/ var/redis/redis.sock/ 5" , Config . new ( path : "/var/redis/redis.sock" , db : 5 ) . server_url
207
+ assert_equal "unix:/// var/redis/redis.sock?db= 5" , Config . new ( path : "/var/redis/redis.sock" , db : 5 ) . server_url
208
208
end
209
209
210
210
def test_custom_field
Original file line number Diff line number Diff line change @@ -319,7 +319,7 @@ def test_protocol_error
319
319
new_client ( host : "127.0.0.1" , port : port ) . call ( "PING" )
320
320
end
321
321
322
- assert_match ( %r{ \( rediss?://127.0.0.1:#{ port } /0 \) $} , error . message )
322
+ assert_match ( %r{ \( rediss?://127.0.0.1:#{ port } \) $} , error . message )
323
323
ensure
324
324
server_thread &.kill
325
325
end
@@ -386,7 +386,7 @@ def test_reconnect_on_readonly
386
386
client . call ( "SET" , "foo" , "bar" )
387
387
end
388
388
refute_predicate client , :connected?
389
- assert_match ( %r{ \( rediss?://127.0.0.1:#{ port } /0 \) $} , error . message )
389
+ assert_match ( %r{ \( rediss?://127.0.0.1:#{ port } \) $} , error . message )
390
390
ensure
391
391
server_thread &.kill
392
392
end
Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ def test_measure_round_trip_delay
127
127
end
128
128
129
129
def test_server_url
130
- assert_equal "redis://#{ Servers ::HOST } :#{ Servers ::REDIS_TCP_PORT } /0 " , @redis . server_url
130
+ assert_equal "redis://#{ Servers ::HOST } :#{ Servers ::REDIS_TCP_PORT } " , @redis . server_url
131
131
end
132
132
133
133
def test_timeout
You can’t perform that action at this time.
0 commit comments