-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelay_test.go
42 lines (31 loc) · 953 Bytes
/
delay_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
37
38
39
40
41
42
package goretry_test
import (
"testing"
"time"
goretry "github.com/IlyasYOY/go-retry"
)
func TestCombineCalculatorWithSelf(t *testing.T) {
calc := goretry.NewConstantDelayCalculator()
combined := calc.With(calc)
result := combined(time.Second)
if result != time.Second {
t.Fatal("result was incorrect", result)
}
}
func TestCombineCalculatorOfDifferentType(t *testing.T) {
incresing := goretry.NewIncreasingDelayCalculator(time.Second)
combined := incresing.With(incresing)
result := combined(time.Second)
if result != time.Second*3 {
t.Fatal("result was incorrect", result)
}
}
func TestCombineCalculatorWithJitter(t *testing.T) {
incresing := goretry.NewIncreasingDelayCalculator(time.Second)
jitting := goretry.NewJittingDelayCalculator(time.Second)
combined := incresing.With(jitting)
result := combined(time.Second)
if result < time.Second || result > time.Second*3 {
t.Fatal("result was incorrect", result)
}
}