6
6
"errors"
7
7
"fmt"
8
8
"net"
9
- "reflect"
10
9
"strconv"
11
10
"strings"
12
11
"sync"
@@ -15,6 +14,7 @@ import (
15
14
16
15
. "github.com/onsi/ginkgo"
17
16
. "github.com/onsi/gomega"
17
+ "github.com/stretchr/testify/assert"
18
18
19
19
"github.com/go-redis/redis/v8"
20
20
"github.com/go-redis/redis/v8/internal/hashtag"
@@ -1300,23 +1300,23 @@ func TestParseClusterURL(t *testing.T) {
1300
1300
}, {
1301
1301
test : "ParseRedissURL" ,
1302
1302
url : "rediss://localhost:123" ,
1303
- o : & redis.ClusterOptions {Addrs : []string {"localhost:123" }, TLSConfig : & tls.Config { /* no deep comparison */ }},
1303
+ o : & redis.ClusterOptions {Addrs : []string {"localhost:123" }, TLSConfig : & tls.Config {ServerName : "localhost" }},
1304
1304
}, {
1305
1305
test : "MissingRedisPort" ,
1306
1306
url : "redis://localhost" ,
1307
1307
o : & redis.ClusterOptions {Addrs : []string {"localhost:6379" }},
1308
1308
}, {
1309
1309
test : "MissingRedissPort" ,
1310
1310
url : "rediss://localhost" ,
1311
- o : & redis.ClusterOptions {Addrs : []string {"localhost:6379" }, TLSConfig : & tls.Config { /* no deep comparison */ }},
1311
+ o : & redis.ClusterOptions {Addrs : []string {"localhost:6379" }, TLSConfig : & tls.Config {ServerName : "localhost" }},
1312
1312
}, {
1313
1313
test : "MultipleRedisURLs" ,
1314
1314
url : "redis://localhost:123?addr=localhost:1234&addr=localhost:12345" ,
1315
- o : & redis.ClusterOptions {Addrs : []string {"localhost:123" , "localhost:12345 " , "localhost:1234 " }},
1315
+ o : & redis.ClusterOptions {Addrs : []string {"localhost:123" , "localhost:1234 " , "localhost:12345 " }},
1316
1316
}, {
1317
1317
test : "MultipleRedissURLs" ,
1318
1318
url : "rediss://localhost:123?addr=localhost:1234&addr=localhost:12345" ,
1319
- o : & redis.ClusterOptions {Addrs : []string {"localhost:123" , "localhost:12345 " , "localhost:1234 " }, TLSConfig : & tls.Config { /* no deep comparison */ }},
1319
+ o : & redis.ClusterOptions {Addrs : []string {"localhost:123" , "localhost:1234 " , "localhost:12345 " }, TLSConfig : & tls.Config {ServerName : "localhost" }},
1320
1320
}, {
1321
1321
test : "OnlyPassword" ,
1322
1322
url : "redis://:bar@localhost:123" ,
@@ -1332,7 +1332,7 @@ func TestParseClusterURL(t *testing.T) {
1332
1332
}, {
1333
1333
test : "RedissUsernamePassword" ,
1334
1334
url : "rediss://foo:bar@localhost:123?addr=localhost:1234" ,
1335
- o : & redis.ClusterOptions {Addrs : []string {"localhost:123" , "localhost:1234" }, Username : "foo" , Password : "bar" , TLSConfig : & tls.Config { /* no deep comparison */ }},
1335
+ o : & redis.ClusterOptions {Addrs : []string {"localhost:123" , "localhost:1234" }, Username : "foo" , Password : "bar" , TLSConfig : & tls.Config {ServerName : "localhost" }},
1336
1336
}, {
1337
1337
test : "QueryParameters" ,
1338
1338
url : "redis://localhost:123?read_timeout=2&pool_fifo=true&addr=localhost:1234" ,
@@ -1403,59 +1403,21 @@ func TestParseClusterURL(t *testing.T) {
1403
1403
1404
1404
func comprareOptions (t * testing.T , actual , expected * redis.ClusterOptions ) {
1405
1405
t .Helper ()
1406
-
1407
- if ! reflect .DeepEqual (actual .Addrs , expected .Addrs ) {
1408
- t .Errorf ("got %q, want %q" , actual .Addrs , expected .Addrs )
1409
- }
1410
- if actual .TLSConfig == nil && expected .TLSConfig != nil {
1411
- t .Errorf ("got nil TLSConfig, expected a TLSConfig" )
1412
- }
1413
- if actual .TLSConfig != nil && expected .TLSConfig == nil {
1414
- t .Errorf ("got TLSConfig, expected no TLSConfig" )
1415
- }
1416
- if actual .Username != expected .Username {
1417
- t .Errorf ("Username: got %q, expected %q" , actual .Username , expected .Username )
1418
- }
1419
- if actual .Password != expected .Password {
1420
- t .Errorf ("Password: got %q, expected %q" , actual .Password , expected .Password )
1421
- }
1422
- if actual .MaxRetries != expected .MaxRetries {
1423
- t .Errorf ("MaxRetries: got %v, expected %v" , actual .MaxRetries , expected .MaxRetries )
1424
- }
1425
- if actual .MinRetryBackoff != expected .MinRetryBackoff {
1426
- t .Errorf ("MinRetryBackoff: got %v, expected %v" , actual .MinRetryBackoff , expected .MinRetryBackoff )
1427
- }
1428
- if actual .MaxRetryBackoff != expected .MaxRetryBackoff {
1429
- t .Errorf ("MaxRetryBackoff: got %v, expected %v" , actual .MaxRetryBackoff , expected .MaxRetryBackoff )
1430
- }
1431
- if actual .DialTimeout != expected .DialTimeout {
1432
- t .Errorf ("DialTimeout: got %v, expected %v" , actual .DialTimeout , expected .DialTimeout )
1433
- }
1434
- if actual .ReadTimeout != expected .ReadTimeout {
1435
- t .Errorf ("ReadTimeout: got %v, expected %v" , actual .ReadTimeout , expected .ReadTimeout )
1436
- }
1437
- if actual .WriteTimeout != expected .WriteTimeout {
1438
- t .Errorf ("WriteTimeout: got %v, expected %v" , actual .WriteTimeout , expected .WriteTimeout )
1439
- }
1440
- if actual .PoolFIFO != expected .PoolFIFO {
1441
- t .Errorf ("PoolFIFO: got %v, expected %v" , actual .PoolFIFO , expected .PoolFIFO )
1442
- }
1443
- if actual .PoolSize != expected .PoolSize {
1444
- t .Errorf ("PoolSize: got %v, expected %v" , actual .PoolSize , expected .PoolSize )
1445
- }
1446
- if actual .MinIdleConns != expected .MinIdleConns {
1447
- t .Errorf ("MinIdleConns: got %v, expected %v" , actual .MinIdleConns , expected .MinIdleConns )
1448
- }
1449
- if actual .MaxConnAge != expected .MaxConnAge {
1450
- t .Errorf ("MaxConnAge: got %v, expected %v" , actual .MaxConnAge , expected .MaxConnAge )
1451
- }
1452
- if actual .PoolTimeout != expected .PoolTimeout {
1453
- t .Errorf ("PoolTimeout: got %v, expected %v" , actual .PoolTimeout , expected .PoolTimeout )
1454
- }
1455
- if actual .IdleTimeout != expected .IdleTimeout {
1456
- t .Errorf ("IdleTimeout: got %v, expected %v" , actual .IdleTimeout , expected .IdleTimeout )
1457
- }
1458
- if actual .IdleCheckFrequency != expected .IdleCheckFrequency {
1459
- t .Errorf ("IdleCheckFrequency: got %v, expected %v" , actual .IdleCheckFrequency , expected .IdleCheckFrequency )
1460
- }
1406
+ assert .Equal (t , expected .Addrs , actual .Addrs )
1407
+ assert .Equal (t , expected .TLSConfig , actual .TLSConfig )
1408
+ assert .Equal (t , expected .Username , actual .Username )
1409
+ assert .Equal (t , expected .Password , actual .Password )
1410
+ assert .Equal (t , expected .MaxRetries , actual .MaxRetries )
1411
+ assert .Equal (t , expected .MinRetryBackoff , actual .MinRetryBackoff )
1412
+ assert .Equal (t , expected .MaxRetryBackoff , actual .MaxRetryBackoff )
1413
+ assert .Equal (t , expected .DialTimeout , actual .DialTimeout )
1414
+ assert .Equal (t , expected .ReadTimeout , actual .ReadTimeout )
1415
+ assert .Equal (t , expected .WriteTimeout , actual .WriteTimeout )
1416
+ assert .Equal (t , expected .PoolFIFO , actual .PoolFIFO )
1417
+ assert .Equal (t , expected .PoolSize , actual .PoolSize )
1418
+ assert .Equal (t , expected .MinIdleConns , actual .MinIdleConns )
1419
+ assert .Equal (t , expected .MaxConnAge , actual .MaxConnAge )
1420
+ assert .Equal (t , expected .PoolTimeout , actual .PoolTimeout )
1421
+ assert .Equal (t , expected .IdleTimeout , actual .IdleTimeout )
1422
+ assert .Equal (t , expected .IdleCheckFrequency , actual .IdleCheckFrequency )
1461
1423
}
0 commit comments