mirror of https://github.com/go-redis/redis.git
commit
7ba7ac4a7f
|
@ -457,6 +457,7 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should Object", func() {
|
It("should Object", func() {
|
||||||
|
start := time.Now()
|
||||||
set := client.Set(ctx, "key", "hello", 0)
|
set := client.Set(ctx, "key", "hello", 0)
|
||||||
Expect(set.Err()).NotTo(HaveOccurred())
|
Expect(set.Err()).NotTo(HaveOccurred())
|
||||||
Expect(set.Val()).To(Equal("OK"))
|
Expect(set.Val()).To(Equal("OK"))
|
||||||
|
@ -470,7 +471,13 @@ var _ = Describe("Commands", func() {
|
||||||
|
|
||||||
idleTime := client.ObjectIdleTime(ctx, "key")
|
idleTime := client.ObjectIdleTime(ctx, "key")
|
||||||
Expect(idleTime.Err()).NotTo(HaveOccurred())
|
Expect(idleTime.Err()).NotTo(HaveOccurred())
|
||||||
Expect(idleTime.Val()).To(Equal(time.Duration(0)))
|
|
||||||
|
//Redis returned milliseconds/1000, which may cause ObjectIdleTime to be at a critical value,
|
||||||
|
//should be +1s to deal with the critical value problem.
|
||||||
|
//if too much time (>1s) is used during command execution, it may also cause the test to fail.
|
||||||
|
//so the ObjectIdleTime result should be <=now-start+1s
|
||||||
|
//link: https://github.com/redis/redis/blob/5b48d900498c85bbf4772c1d466c214439888115/src/object.c#L1265-L1272
|
||||||
|
Expect(idleTime.Val()).To(BeNumerically("<=", time.Now().Sub(start) + time.Second))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should Persist", func() {
|
It("should Persist", func() {
|
||||||
|
@ -1458,7 +1465,7 @@ var _ = Describe("Commands", func() {
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should SetEX", func() {
|
It("should SetEX", func() {
|
||||||
err := client.SetEX(ctx, "key", "hello", 100*time.Millisecond).Err()
|
err := client.SetEX(ctx, "key", "hello", 1*time.Second).Err()
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
val, err := client.Get(ctx, "key").Result()
|
val, err := client.Get(ctx, "key").Result()
|
||||||
|
@ -1467,7 +1474,7 @@ var _ = Describe("Commands", func() {
|
||||||
|
|
||||||
Eventually(func() error {
|
Eventually(func() error {
|
||||||
return client.Get(ctx, "foo").Err()
|
return client.Get(ctx, "foo").Err()
|
||||||
}, "1s", "100ms").Should(Equal(redis.Nil))
|
}, "2s", "100ms").Should(Equal(redis.Nil))
|
||||||
})
|
})
|
||||||
|
|
||||||
It("should SetNX", func() {
|
It("should SetNX", func() {
|
||||||
|
|
Loading…
Reference in New Issue