@@ -640,6 +640,13 @@ var dialURLTests = []struct {
640640 w string
641641}{
642642 {"password" , "redis://:abc123@localhost" , "+OK\r \n " , "*2\r \n $4\r \n AUTH\r \n $6\r \n abc123\r \n " },
643+ {"password redis-cli compat" , "redis://abc123@localhost" , "+OK\r \n " , "*2\r \n $4\r \n AUTH\r \n $6\r \n abc123\r \n " },
644+ {"password db1" , "redis://:abc123@localhost/1" , "+OK\r \n +OK\r \n " , "*2\r \n $4\r \n AUTH\r \n $6\r \n abc123\r \n *2\r \n $6\r \n SELECT\r \n $1\r \n 1\r \n " },
645+ {"password db1 redis-cli compat" , "redis://abc123@localhost/1" , "+OK\r \n +OK\r \n " , "*2\r \n $4\r \n AUTH\r \n $6\r \n abc123\r \n *2\r \n $6\r \n SELECT\r \n $1\r \n 1\r \n " },
646+ {"password no host db0" , "redis://:abc123@/0" , "+OK\r \n +OK\r \n " , "*2\r \n $4\r \n AUTH\r \n $6\r \n abc123\r \n " },
647+ {"password no host db0 redis-cli compat" , "redis://abc123@/0" , "+OK\r \n +OK\r \n " , "*2\r \n $4\r \n AUTH\r \n $6\r \n abc123\r \n " },
648+ {"password no host db1" , "redis://:abc123@/1" , "+OK\r \n +OK\r \n " , "*2\r \n $4\r \n AUTH\r \n $6\r \n abc123\r \n *2\r \n $6\r \n SELECT\r \n $1\r \n 1\r \n " },
649+ {"password no host db1 redis-cli compat" , "redis://abc123@/1" , "+OK\r \n +OK\r \n " , "*2\r \n $4\r \n AUTH\r \n $6\r \n abc123\r \n *2\r \n $6\r \n SELECT\r \n $1\r \n 1\r \n " },
643650 {"username and password" , "redis://user:password@localhost" , "+OK\r \n " , "*3\r \n $4\r \n AUTH\r \n $4\r \n user\r \n $8\r \n password\r \n " },
644651 {"username" , "redis://x:@localhost" , "+OK\r \n " , "" },
645652 {"database 3" , "redis://localhost/3" , "+OK\r \n " , "*2\r \n $6\r \n SELECT\r \n $1\r \n 3\r \n " },
@@ -649,16 +656,18 @@ var dialURLTests = []struct {
649656
650657func TestDialURL (t * testing.T ) {
651658 for _ , tt := range dialURLTests {
652- var buf bytes.Buffer
653- // UseTLS should be ignored in all of these tests.
654- _ , err := redis .DialURL (tt .url , dialTestConn (tt .r , & buf ), redis .DialUseTLS (true ))
655- if err != nil {
656- t .Errorf ("%s dial error: %v" , tt .description , err )
657- continue
658- }
659- if w := buf .String (); w != tt .w {
660- t .Errorf ("%s commands = %q, want %q" , tt .description , w , tt .w )
661- }
659+ t .Run (tt .description , func (t * testing.T ) {
660+ var buf bytes.Buffer
661+ // UseTLS should be ignored in all of these tests.
662+ _ , err := redis .DialURL (tt .url , dialTestConn (tt .r , & buf ), redis .DialUseTLS (true ))
663+ if err != nil {
664+ t .Errorf ("%s dial error: %v, buf: %v" , tt .description , err , buf .String ())
665+ return
666+ }
667+ if w := buf .String (); w != tt .w {
668+ t .Errorf ("%s commands = %q, want %q" , tt .description , w , tt .w )
669+ }
670+ })
662671 }
663672}
664673
0 commit comments