From 3fc16811b5b8a77c9c5b541c3c1d6525bb38f2d9 Mon Sep 17 00:00:00 2001 From: Vladimir Mihailenco Date: Wed, 3 Jun 2015 15:09:56 +0300 Subject: [PATCH] Fix flaky tests by using better matcher. --- commands_test.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/commands_test.go b/commands_test.go index 0d19b2e5..ef593e1e 100644 --- a/commands_test.go +++ b/commands_test.go @@ -369,8 +369,7 @@ var _ = Describe("Commands", func() { pttl := client.PTTL("key") Expect(pttl.Err()).NotTo(HaveOccurred()) - Expect(pttl.Val() <= expiration).To(Equal(true)) - Expect(pttl.Val() >= expiration-time.Millisecond).To(Equal(true)) + Expect(pttl.Val()).To(BeNumerically("~", expiration, 10*time.Millisecond)) }) It("should PExpireAt", func() { @@ -389,8 +388,7 @@ var _ = Describe("Commands", func() { pttl := client.PTTL("key") Expect(pttl.Err()).NotTo(HaveOccurred()) - Expect(pttl.Val() <= expiration).To(Equal(true)) - Expect(pttl.Val() >= expiration-time.Millisecond).To(Equal(true)) + Expect(pttl.Val()).To(BeNumerically("~", expiration, 10*time.Millisecond)) }) It("should PTTL", func() { @@ -405,8 +403,7 @@ var _ = Describe("Commands", func() { pttl := client.PTTL("key") Expect(pttl.Err()).NotTo(HaveOccurred()) - Expect(pttl.Val() <= expiration).To(Equal(true)) - Expect(pttl.Val() >= expiration-time.Millisecond).To(Equal(true)) + Expect(pttl.Val()).To(BeNumerically("~", expiration, 10*time.Millisecond)) }) It("should RandomKey", func() {