Add test for SetXX with expiration = 0

This commit is contained in:
Borys Piddubnyi 2016-10-21 17:14:51 +03:00
parent 50f1aff778
commit cb63f1fd69
1 changed files with 17 additions and 0 deletions

View File

@ -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))