universal_test.go 935 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package redis_test
  2. import (
  3. . "github.com/onsi/ginkgo"
  4. . "github.com/onsi/gomega"
  5. "github.com/go-redis/redis"
  6. )
  7. var _ = Describe("UniversalClient", func() {
  8. var client redis.UniversalClient
  9. AfterEach(func() {
  10. if client != nil {
  11. Expect(client.Close()).To(Succeed())
  12. }
  13. })
  14. It("should connect to failover servers", func() {
  15. client = redis.NewUniversalClient(&redis.UniversalOptions{
  16. MasterName: sentinelName,
  17. Addrs: []string{":" + sentinelPort},
  18. })
  19. Expect(client.Ping().Err()).NotTo(HaveOccurred())
  20. })
  21. It("should connect to simple servers", func() {
  22. client = redis.NewUniversalClient(&redis.UniversalOptions{
  23. Addrs: []string{redisAddr},
  24. })
  25. Expect(client.Ping().Err()).NotTo(HaveOccurred())
  26. })
  27. It("should connect to clusters", func() {
  28. client = redis.NewUniversalClient(&redis.UniversalOptions{
  29. Addrs: cluster.addrs(),
  30. })
  31. Expect(client.Ping().Err()).NotTo(HaveOccurred())
  32. })
  33. })