MCPcopy
hub / github.com/cenkalti/backoff / TestBackOffOverflow

Function TestBackOffOverflow

exponential_test.go:53–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51}
52
53func TestBackOffOverflow(t *testing.T) {
54 var (
55 testInitialInterval time.Duration = math.MaxInt64 / 2
56 testMaxInterval time.Duration = math.MaxInt64
57 testMultiplier = 2.1
58 )
59
60 exp := NewExponentialBackOff()
61 exp.InitialInterval = testInitialInterval
62 exp.Multiplier = testMultiplier
63 exp.MaxInterval = testMaxInterval
64 exp.Reset()
65
66 exp.NextBackOff()
67 // Assert that when an overflow is possible, the current interval time.Duration is set to the max interval time.Duration.
68 assertEquals(t, testMaxInterval, exp.currentInterval)
69}
70
71func assertEquals(t *testing.T, expected, value time.Duration) {
72 if expected != value {

Callers

nothing calls this directly

Calls 4

ResetMethod · 0.95
NextBackOffMethod · 0.95
NewExponentialBackOffFunction · 0.85
assertEqualsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…