MCPcopy
hub / github.com/bsm/redislock / TestExponentialBackoff

Function TestExponentialBackoff

retry_test.go:32–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func TestExponentialBackoff(t *testing.T) {
33 retry := ExponentialBackoff(10*time.Millisecond, 300*time.Millisecond)
34 for i, exp := range []time.Duration{
35 10 * time.Millisecond,
36 10 * time.Millisecond,
37 16 * time.Millisecond,
38 32 * time.Millisecond,
39 64 * time.Millisecond,
40 128 * time.Millisecond,
41 256 * time.Millisecond,
42 300 * time.Millisecond,
43 300 * time.Millisecond,
44 } {
45 if got := retry.NextBackoff(); exp != got {
46 t.Fatalf("expected %d to be %v, got %v", i, exp, got)
47 }
48 }
49}
50
51func TestLimitRetry(t *testing.T) {
52 retry := LimitRetry(LinearBackoff(time.Second), 2)

Callers

nothing calls this directly

Calls 2

ExponentialBackoffFunction · 0.85
NextBackoffMethod · 0.65

Tested by

no test coverage detected