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"
|
||||
"strings"
|
||||
"sync"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
. "github.com/bsm/ginkgo/v2"
|
||||
. "github.com/bsm/gomega"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
"github.com/redis/go-redis/v9/internal/hashtag"
|
||||
)
|
||||
|
@ -1360,8 +1357,8 @@ var _ = Describe("ClusterClient timeout", func() {
|
|||
})
|
||||
})
|
||||
|
||||
func TestParseClusterURL(t *testing.T) {
|
||||
cases := []struct {
|
||||
var _ = Describe("ClusterClient ParseURL", func() {
|
||||
var cases = []struct {
|
||||
test string
|
||||
url string
|
||||
o *redis.ClusterOptions // expected value
|
||||
|
@ -1454,47 +1451,36 @@ func TestParseClusterURL(t *testing.T) {
|
|||
},
|
||||
}
|
||||
|
||||
for i := range cases {
|
||||
tc := cases[i]
|
||||
t.Run(tc.test, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
It("match ParseClusterURL", func() {
|
||||
for i := range cases {
|
||||
tc := cases[i]
|
||||
actual, err := redis.ParseClusterURL(tc.url)
|
||||
if tc.err == nil && err != nil {
|
||||
t.Fatalf("unexpected error: %q", err)
|
||||
return
|
||||
if tc.err != nil {
|
||||
Expect(err).Should(MatchError(tc.err))
|
||||
} 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) {
|
||||
t.Helper()
|
||||
assert.Equal(t, expected.Addrs, actual.Addrs)
|
||||
assert.Equal(t, expected.TLSConfig, actual.TLSConfig)
|
||||
assert.Equal(t, expected.Username, actual.Username)
|
||||
assert.Equal(t, expected.Password, actual.Password)
|
||||
assert.Equal(t, expected.MaxRetries, actual.MaxRetries)
|
||||
assert.Equal(t, expected.MinRetryBackoff, actual.MinRetryBackoff)
|
||||
assert.Equal(t, expected.MaxRetryBackoff, actual.MaxRetryBackoff)
|
||||
assert.Equal(t, expected.DialTimeout, actual.DialTimeout)
|
||||
assert.Equal(t, expected.ReadTimeout, actual.ReadTimeout)
|
||||
assert.Equal(t, expected.WriteTimeout, actual.WriteTimeout)
|
||||
assert.Equal(t, expected.PoolFIFO, actual.PoolFIFO)
|
||||
assert.Equal(t, expected.PoolSize, actual.PoolSize)
|
||||
assert.Equal(t, expected.MinIdleConns, actual.MinIdleConns)
|
||||
assert.Equal(t, expected.ConnMaxLifetime, actual.ConnMaxLifetime)
|
||||
assert.Equal(t, expected.ConnMaxIdleTime, actual.ConnMaxIdleTime)
|
||||
assert.Equal(t, expected.PoolTimeout, actual.PoolTimeout)
|
||||
}
|
||||
if err == nil {
|
||||
Expect(tc.o).NotTo(BeNil())
|
||||
|
||||
Expect(tc.o.Addrs).To(Equal(actual.Addrs))
|
||||
Expect(tc.o.TLSConfig).To(Equal(actual.TLSConfig))
|
||||
Expect(tc.o.Username).To(Equal(actual.Username))
|
||||
Expect(tc.o.Password).To(Equal(actual.Password))
|
||||
Expect(tc.o.MaxRetries).To(Equal(actual.MaxRetries))
|
||||
Expect(tc.o.MinRetryBackoff).To(Equal(actual.MinRetryBackoff))
|
||||
Expect(tc.o.MaxRetryBackoff).To(Equal(actual.MaxRetryBackoff))
|
||||
Expect(tc.o.DialTimeout).To(Equal(actual.DialTimeout))
|
||||
Expect(tc.o.ReadTimeout).To(Equal(actual.ReadTimeout))
|
||||
Expect(tc.o.WriteTimeout).To(Equal(actual.WriteTimeout))
|
||||
Expect(tc.o.PoolFIFO).To(Equal(actual.PoolFIFO))
|
||||
Expect(tc.o.PoolSize).To(Equal(actual.PoolSize))
|
||||
Expect(tc.o.MinIdleConns).To(Equal(actual.MinIdleConns))
|
||||
Expect(tc.o.ConnMaxLifetime).To(Equal(actual.ConnMaxLifetime))
|
||||
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/cespare/xxhash/v2 v2.2.0
|
||||
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/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||
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/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