2017-02-17 13:12:06 +03:00
|
|
|
package redis_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
|
2019-08-08 14:29:44 +03:00
|
|
|
"github.com/go-redis/redis/v7"
|
2017-02-17 13:12:06 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
var _ = Describe("UniversalClient", func() {
|
|
|
|
var client redis.UniversalClient
|
|
|
|
|
|
|
|
AfterEach(func() {
|
|
|
|
if client != nil {
|
|
|
|
Expect(client.Close()).To(Succeed())
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
It("should connect to failover servers", func() {
|
|
|
|
client = redis.NewUniversalClient(&redis.UniversalOptions{
|
|
|
|
MasterName: sentinelName,
|
|
|
|
Addrs: []string{":" + sentinelPort},
|
|
|
|
})
|
2020-03-11 17:26:42 +03:00
|
|
|
Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred())
|
2017-02-17 13:12:06 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should connect to simple servers", func() {
|
|
|
|
client = redis.NewUniversalClient(&redis.UniversalOptions{
|
|
|
|
Addrs: []string{redisAddr},
|
|
|
|
})
|
2020-03-11 17:26:42 +03:00
|
|
|
Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred())
|
2017-02-17 13:12:06 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should connect to clusters", func() {
|
|
|
|
client = redis.NewUniversalClient(&redis.UniversalOptions{
|
|
|
|
Addrs: cluster.addrs(),
|
|
|
|
})
|
2020-03-11 17:26:42 +03:00
|
|
|
Expect(client.Ping(ctx).Err()).NotTo(HaveOccurred())
|
2017-02-17 13:12:06 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
})
|