test: add test case for setting and scanning durations

This commit is contained in:
Jackie 2021-10-23 00:10:30 +02:00
parent 2f1b74e20c
commit a2a463b123
1 changed files with 12 additions and 0 deletions

View File

@ -300,6 +300,18 @@ var _ = Describe("Client", func() {
Expect(tm2).To(BeTemporally("==", tm)) Expect(tm2).To(BeTemporally("==", tm))
}) })
It("should set and scan durations", func() {
duration := 10 * time.Minute
err := client.Set(ctx, "duration", duration, 0).Err()
Expect(err).NotTo(HaveOccurred())
var duration2 time.Duration
err = client.Get(ctx, "duration").Scan(&duration2)
Expect(err).NotTo(HaveOccurred())
Expect(duration2).To(Equal(duration))
})
It("should Conn", func() { It("should Conn", func() {
err := client.Conn(ctx).Get(ctx, "this-key-does-not-exist").Err() err := client.Conn(ctx).Get(ctx, "this-key-does-not-exist").Err()
Expect(err).To(Equal(redis.Nil)) Expect(err).To(Equal(redis.Nil))