@@ -17,18 +17,18 @@ func TestCalculateBackoff(t *testing.T) {
1717 expectedMin time.Duration
1818 expectedMax time.Duration
1919 }{
20- {retry : 0 , expectedMin : baseDelay , expectedMax : maxDelay },
21- {retry : 1 , expectedMin : baseDelay * 2 , expectedMax : maxDelay },
22- {retry : 2 , expectedMin : baseDelay * 4 , expectedMax : maxDelay },
23- {retry : 5 , expectedMin : baseDelay * 32 , expectedMax : maxDelay },
20+ {retry : 0 , expectedMin : time . Duration ( float64 ( baseDelay ) * ( 1 - jitterFactor )) , expectedMax : maxDelay },
21+ {retry : 1 , expectedMin : time . Duration ( float64 ( baseDelay * 2 ) * ( 1 - jitterFactor )) , expectedMax : maxDelay },
22+ {retry : 2 , expectedMin : time . Duration ( float64 ( baseDelay * 4 ) * ( 1 - jitterFactor )) , expectedMax : maxDelay },
23+ {retry : 5 , expectedMin : time . Duration ( float64 ( baseDelay * 32 ) * ( 1 - jitterFactor )) , expectedMax : maxDelay },
2424 }
2525
2626 for _ , tt := range tests {
2727 t .Run ("RetryCount" + strconv .Itoa (tt .retry ), func (t * testing.T ) {
2828 delay := calculateBackoff (tt .retry )
2929
3030 // The delay should be within the expected range
31- assert .GreaterOrEqual (t , delay , tt .expectedMin , "Delay should be greater than or equal to expected minimum" )
31+ assert .GreaterOrEqual (t , delay , tt .expectedMin , "Delay should be greater than or equal to expected minimum after jitter adjustment " )
3232 assert .LessOrEqual (t , delay , tt .expectedMax , "Delay should be less than or equal to expected maximum" )
3333 })
3434 }
0 commit comments