From cb63f1fd691953c8d4aeb4abfbba98cea7da1e9c Mon Sep 17 00:00:00 2001 From: Borys Piddubnyi Date: Fri, 21 Oct 2016 17:14:51 +0300 Subject: [PATCH] Add test for SetXX with expiration = 0 --- commands_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/commands_test.go b/commands_test.go index e613d4a..3f4f2c8 100644 --- a/commands_test.go +++ b/commands_test.go @@ -996,6 +996,23 @@ var _ = Describe("Commands", func() { }) It("should SetXX", func() { + isSet, err := client.SetXX("key", "hello2", 0).Result() + Expect(err).NotTo(HaveOccurred()) + Expect(isSet).To(Equal(false)) + + err = client.Set("key", "hello", 0).Err() + Expect(err).NotTo(HaveOccurred()) + + isSet, err = client.SetXX("key", "hello2", 0).Result() + Expect(err).NotTo(HaveOccurred()) + Expect(isSet).To(Equal(true)) + + val, err := client.Get("key").Result() + Expect(err).NotTo(HaveOccurred()) + Expect(val).To(Equal("hello2")) + }) + + It("should SetXX with expiration", func() { isSet, err := client.SetXX("key", "hello2", time.Second).Result() Expect(err).NotTo(HaveOccurred()) Expect(isSet).To(Equal(false))