From e075ad33d33d48923b5e964f9be7abd2e67795fa Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Tue, 27 Feb 2018 16:09:55 +0200 Subject: [PATCH] Simplify test --- redis_test.go | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/redis_test.go b/redis_test.go index 49d3fb32..ad8aa11a 100644 --- a/redis_test.go +++ b/redis_test.go @@ -157,30 +157,15 @@ var _ = Describe("Client", func() { }) It("should retry with backoff", func() { - Expect(client.Close()).NotTo(HaveOccurred()) - - // use up all the available connections to force a fail - connectionHogClient := redis.NewClient(&redis.Options{ - Addr: redisAddr, - MaxRetries: 1, - }) - defer connectionHogClient.Close() - - for i := 0; i <= 1002; i++ { - connectionHogClient.Pool().NewConn() - } - clientNoRetry := redis.NewClient(&redis.Options{ - Addr: redisAddr, - PoolSize: 1, - MaxRetryBackoff: -1, + Addr: ":1234", + MaxRetries: 0, }) defer clientNoRetry.Close() clientRetry := redis.NewClient(&redis.Options{ - Addr: redisAddr, + Addr: ":1234", MaxRetries: 5, - PoolSize: 1, MaxRetryBackoff: 128 * time.Millisecond, }) defer clientRetry.Close() @@ -195,7 +180,7 @@ var _ = Describe("Client", func() { Expect(err).To(HaveOccurred()) elapseRetry := time.Since(startRetry) - Expect(elapseRetry > elapseNoRetry).To(BeTrue()) + Expect(elapseRetry).To(BeNumerically(">", elapseNoRetry, 10*time.Millisecond)) }) It("should update conn.UsedAt on read/write", func() {