@@ -73,6 +73,8 @@ func TestAllowAtMostN(t *testing.T) {
7373 assert .Nil (t , err )
7474 assert .Equal (t , res .Allowed , 2 )
7575 assert .Equal (t , res .Remaining , 7 )
76+ assert .Equal (t , res .RetryAfter , time .Duration (- 1 ))
77+ assert .InDelta (t , res .ResetAfter , 300 * time .Millisecond , float64 (10 * time .Millisecond ))
7678
7779 res , err = l .AllowN (ctx , "test_id" , limit , 0 )
7880 assert .Nil (t , err )
@@ -85,6 +87,8 @@ func TestAllowAtMostN(t *testing.T) {
8587 assert .Nil (t , err )
8688 assert .Equal (t , res .Allowed , 7 )
8789 assert .Equal (t , res .Remaining , 0 )
90+ assert .Equal (t , res .RetryAfter , time .Duration (- 1 ))
91+ assert .InDelta (t , res .ResetAfter , 999 * time .Millisecond , float64 (10 * time .Millisecond ))
8892
8993 res , err = l .AllowN (ctx , "test_id" , limit , 0 )
9094 assert .Nil (t , err )
@@ -97,6 +101,8 @@ func TestAllowAtMostN(t *testing.T) {
97101 assert .Nil (t , err )
98102 assert .Equal (t , res .Allowed , 0 )
99103 assert .Equal (t , res .Remaining , 0 )
104+ assert .InDelta (t , res .RetryAfter , 99 * time .Millisecond , float64 (10 * time .Millisecond ))
105+ assert .InDelta (t , res .ResetAfter , 999 * time .Millisecond , float64 (10 * time .Millisecond ))
100106
101107 res , err = l .AllowN (ctx , "test_id" , limit , 1000 )
102108 assert .Nil (t , err )
0 commit comments