forked from cenkalti/backoff
-
Notifications
You must be signed in to change notification settings - Fork 1
/
linear_test.go
36 lines (26 loc) · 939 Bytes
/
linear_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package backoff
import (
"testing"
"time"
)
func TestLinear(t *testing.T) {
bmult := NewLinear(time.Minute, 10*time.Minute, 0, 4)
bmult.increment()
if bmult.currentInterval != time.Minute*4 {
t.Errorf("increment did not work got %s expected %s.", bmult.currentInterval, time.Minute*2)
}
bincr := NewLinear(time.Minute, 10*time.Minute, time.Minute, 1)
bincr.increment()
if bincr.currentInterval != time.Minute*2 {
t.Errorf("increment did not work got %s expected %s.", bincr.currentInterval, time.Minute*2)
}
bmultincr := NewLinear(time.Minute, 10*time.Minute, time.Minute, 2)
bmultincr.increment()
if bmultincr.currentInterval != time.Minute*3 {
t.Errorf("increment did not work got %s expected %s.", bmultincr.currentInterval, time.Minute*3)
}
bmultincr.Reset()
if bmultincr.currentInterval != time.Minute {
t.Errorf("reset did not work got %s expected %s.", bmultincr.currentInterval, time.Minute)
}
}