File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -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 () {
You can’t perform that action at this time.
0 commit comments