mirror of https://github.com/go-redis/redis.git
test: remove testify (#2463)
* test: remove testify Signed-off-by: monkey92t <golang@88.com>
This commit is contained in:
parent
e309eaf915
commit
73d939e7bf
|
@ -9,13 +9,10 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
. "github.com/bsm/ginkgo/v2"
|
. "github.com/bsm/ginkgo/v2"
|
||||||
. "github.com/bsm/gomega"
|
. "github.com/bsm/gomega"
|
||||||
"github.com/stretchr/testify/assert"
|
|
||||||
|
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
"github.com/redis/go-redis/v9/internal/hashtag"
|
"github.com/redis/go-redis/v9/internal/hashtag"
|
||||||
)
|
)
|
||||||
|
@ -1360,8 +1357,8 @@ var _ = Describe("ClusterClient timeout", func() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
func TestParseClusterURL(t *testing.T) {
|
var _ = Describe("ClusterClient ParseURL", func() {
|
||||||
cases := []struct {
|
var cases = []struct {
|
||||||
test string
|
test string
|
||||||
url string
|
url string
|
||||||
o *redis.ClusterOptions // expected value
|
o *redis.ClusterOptions // expected value
|
||||||
|
@ -1454,47 +1451,36 @@ func TestParseClusterURL(t *testing.T) {
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
It("match ParseClusterURL", func() {
|
||||||
for i := range cases {
|
for i := range cases {
|
||||||
tc := cases[i]
|
tc := cases[i]
|
||||||
t.Run(tc.test, func(t *testing.T) {
|
|
||||||
t.Parallel()
|
|
||||||
|
|
||||||
actual, err := redis.ParseClusterURL(tc.url)
|
actual, err := redis.ParseClusterURL(tc.url)
|
||||||
if tc.err == nil && err != nil {
|
if tc.err != nil {
|
||||||
t.Fatalf("unexpected error: %q", err)
|
Expect(err).Should(MatchError(tc.err))
|
||||||
return
|
} else {
|
||||||
|
Expect(err).NotTo(HaveOccurred())
|
||||||
}
|
}
|
||||||
if tc.err != nil && err == nil {
|
|
||||||
t.Fatalf("expected error: got %+v", actual)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if tc.err != nil && err != nil {
|
|
||||||
if tc.err.Error() != err.Error() {
|
|
||||||
t.Fatalf("got %q, expected %q", err, tc.err)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
comprareOptions(t, actual, tc.o)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func comprareOptions(t *testing.T, actual, expected *redis.ClusterOptions) {
|
if err == nil {
|
||||||
t.Helper()
|
Expect(tc.o).NotTo(BeNil())
|
||||||
assert.Equal(t, expected.Addrs, actual.Addrs)
|
|
||||||
assert.Equal(t, expected.TLSConfig, actual.TLSConfig)
|
Expect(tc.o.Addrs).To(Equal(actual.Addrs))
|
||||||
assert.Equal(t, expected.Username, actual.Username)
|
Expect(tc.o.TLSConfig).To(Equal(actual.TLSConfig))
|
||||||
assert.Equal(t, expected.Password, actual.Password)
|
Expect(tc.o.Username).To(Equal(actual.Username))
|
||||||
assert.Equal(t, expected.MaxRetries, actual.MaxRetries)
|
Expect(tc.o.Password).To(Equal(actual.Password))
|
||||||
assert.Equal(t, expected.MinRetryBackoff, actual.MinRetryBackoff)
|
Expect(tc.o.MaxRetries).To(Equal(actual.MaxRetries))
|
||||||
assert.Equal(t, expected.MaxRetryBackoff, actual.MaxRetryBackoff)
|
Expect(tc.o.MinRetryBackoff).To(Equal(actual.MinRetryBackoff))
|
||||||
assert.Equal(t, expected.DialTimeout, actual.DialTimeout)
|
Expect(tc.o.MaxRetryBackoff).To(Equal(actual.MaxRetryBackoff))
|
||||||
assert.Equal(t, expected.ReadTimeout, actual.ReadTimeout)
|
Expect(tc.o.DialTimeout).To(Equal(actual.DialTimeout))
|
||||||
assert.Equal(t, expected.WriteTimeout, actual.WriteTimeout)
|
Expect(tc.o.ReadTimeout).To(Equal(actual.ReadTimeout))
|
||||||
assert.Equal(t, expected.PoolFIFO, actual.PoolFIFO)
|
Expect(tc.o.WriteTimeout).To(Equal(actual.WriteTimeout))
|
||||||
assert.Equal(t, expected.PoolSize, actual.PoolSize)
|
Expect(tc.o.PoolFIFO).To(Equal(actual.PoolFIFO))
|
||||||
assert.Equal(t, expected.MinIdleConns, actual.MinIdleConns)
|
Expect(tc.o.PoolSize).To(Equal(actual.PoolSize))
|
||||||
assert.Equal(t, expected.ConnMaxLifetime, actual.ConnMaxLifetime)
|
Expect(tc.o.MinIdleConns).To(Equal(actual.MinIdleConns))
|
||||||
assert.Equal(t, expected.ConnMaxIdleTime, actual.ConnMaxIdleTime)
|
Expect(tc.o.ConnMaxLifetime).To(Equal(actual.ConnMaxLifetime))
|
||||||
assert.Equal(t, expected.PoolTimeout, actual.PoolTimeout)
|
Expect(tc.o.ConnMaxIdleTime).To(Equal(actual.ConnMaxIdleTime))
|
||||||
}
|
Expect(tc.o.PoolTimeout).To(Equal(actual.PoolTimeout))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
7
go.mod
7
go.mod
|
@ -7,11 +7,4 @@ require (
|
||||||
github.com/bsm/gomega v1.26.0
|
github.com/bsm/gomega v1.26.0
|
||||||
github.com/cespare/xxhash/v2 v2.2.0
|
github.com/cespare/xxhash/v2 v2.2.0
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f
|
||||||
github.com/stretchr/testify v1.8.1
|
|
||||||
)
|
|
||||||
|
|
||||||
require (
|
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
|
||||||
)
|
)
|
||||||
|
|
17
go.sum
17
go.sum
|
@ -4,22 +4,5 @@ github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y=
|
||||||
github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
github.com/bsm/gomega v1.26.0/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
|
||||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
|
||||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
|
||||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
|
||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
|
||||||
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
|
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
|
|
Loading…
Reference in New Issue