@@ -457,6 +457,7 @@ var _ = Describe("Commands", func() {
457
457
})
458
458
459
459
It ("should Object" , func () {
460
+ start := time .Now ()
460
461
set := client .Set (ctx , "key" , "hello" , 0 )
461
462
Expect (set .Err ()).NotTo (HaveOccurred ())
462
463
Expect (set .Val ()).To (Equal ("OK" ))
@@ -470,7 +471,13 @@ var _ = Describe("Commands", func() {
470
471
471
472
idleTime := client .ObjectIdleTime (ctx , "key" )
472
473
Expect (idleTime .Err ()).NotTo (HaveOccurred ())
473
- Expect (idleTime .Val ()).To (Equal (time .Duration (0 )))
474
+
475
+ //Redis returned milliseconds/1000, which may cause ObjectIdleTime to be at a critical value,
476
+ //should be +1s to deal with the critical value problem.
477
+ //if too much time (>1s) is used during command execution, it may also cause the test to fail.
478
+ //so the ObjectIdleTime result should be <=now-start+1s
479
+ //link: https://github.com/redis/redis/blob/5b48d900498c85bbf4772c1d466c214439888115/src/object.c#L1265-L1272
480
+ Expect (idleTime .Val ()).To (BeNumerically ("<=" , time .Now ().Sub (start ) + time .Second ))
474
481
})
475
482
476
483
It ("should Persist" , func () {
@@ -1458,7 +1465,7 @@ var _ = Describe("Commands", func() {
1458
1465
})
1459
1466
1460
1467
It ("should SetEX" , func () {
1461
- err := client .SetEX (ctx , "key" , "hello" , 100 * time .Millisecond ).Err ()
1468
+ err := client .SetEX (ctx , "key" , "hello" , 1 * time .Second ).Err ()
1462
1469
Expect (err ).NotTo (HaveOccurred ())
1463
1470
1464
1471
val , err := client .Get (ctx , "key" ).Result ()
@@ -1467,7 +1474,7 @@ var _ = Describe("Commands", func() {
1467
1474
1468
1475
Eventually (func () error {
1469
1476
return client .Get (ctx , "foo" ).Err ()
1470
- }, "1s " , "100ms" ).Should (Equal (redis .Nil ))
1477
+ }, "2s " , "100ms" ).Should (Equal (redis .Nil ))
1471
1478
})
1472
1479
1473
1480
It ("should SetNX" , func () {
0 commit comments