-
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow connection to redis using uri
closes: #1010
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,29 @@ func TestCreateOptions(t *testing.T) { | |
Password: "test", | ||
}, | ||
}, | ||
"test with uri no ssl": { | ||
config: map[string]interface{}{ | ||
"uri": "redis://user:[email protected]:6379/0", | ||
}, | ||
expected: &goredis.Options{ | ||
Network: "tcp", | ||
DB: 0, | ||
Addr: "127.0.0.1:6379", | ||
Password: "test", | ||
}, | ||
}, | ||
"test with uri with ssl": { | ||
config: map[string]interface{}{ | ||
"uri": "rediss://user:[email protected]:6379/0", | ||
}, | ||
expected: &goredis.Options{ | ||
Network: "tcp", | ||
DB: 0, | ||
Addr: "127.0.0.1:6379", | ||
Password: "test", | ||
TLSConfig: &tls.Config{ /* no deep comparison */ }, | ||
}, | ||
}, | ||
"test empty config": { | ||
config: map[string]interface{}{}, | ||
expected: &goredis.Options{ | ||
|
@@ -274,6 +297,11 @@ func TestNew(t *testing.T) { | |
"ssl": false, | ||
}, | ||
}, | ||
"explicit config with uri": { | ||
config: map[string]interface{}{ | ||
"uri": "redis://127.0.0.1:6379/0", | ||
}, | ||
}, | ||
"implicit config": { | ||
config: map[string]interface{}{}, | ||
}, | ||
|
@@ -285,6 +313,14 @@ func TestNew(t *testing.T) { | |
T: reflect.TypeOf(""), | ||
}, | ||
}, | ||
"bad config uri": { | ||
config: map[string]interface{}{"uri": 1}, | ||
expectedErr: dict.ErrKeyType{ | ||
Key: "uri", | ||
Value: 1, | ||
T: reflect.TypeOf(""), | ||
}, | ||
}, | ||
"bad config ttl": { | ||
config: map[string]interface{}{"ttl": "fails"}, | ||
expectedErr: dict.ErrKeyType{ | ||
|