forked from choria-io/asyncjobs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathretrypolicy_test.go
44 lines (37 loc) · 1.18 KB
/
retrypolicy_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
43
44
package asyncjobs
import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)
var _ = Describe("RetryPolicy", func() {
Describe("Duration", func() {
It("Should determine the correct interval with jitter", func() {
b := RetryLinearOneMinute.Duration(10)
d := RetryLinearOneMinute.Intervals[10]
Expect(b).ToNot(Equal(d))
Expect(b).To(BeNumerically(">", float64(d)*0.5))
Expect(b).To(BeNumerically("<", float64(d)+float64(d)*0.5))
})
})
Describe("RetryPolicyNames", func() {
It("Should have the right names", func() {
Expect(RetryPolicyNames()).To(Equal([]string{"10m", "1h", "1m", "default"}))
})
})
Describe("RetryPolicyLookup", func() {
It("Should find the right policy", func() {
_, err := RetryPolicyLookup("missing")
Expect(err).To(MatchError(ErrUnknownRetryPolicy))
p, err := RetryPolicyLookup("1m")
Expect(err).ToNot(HaveOccurred())
Expect(p).To(Equal(RetryLinearOneMinute))
})
})
Describe("IsRetryPolicyKnown", func() {
It("Should report correct values", func() {
Expect(IsRetryPolicyKnown("foo")).To(BeFalse())
Expect(IsRetryPolicyKnown("default")).To(BeTrue())
Expect(IsRetryPolicyKnown("1m")).To(BeTrue())
})
})
})