(t *testing.T)
| 6 | ) |
| 7 | |
| 8 | func TestBackoffDelay(t *testing.T) { |
| 9 | cases := []struct { |
| 10 | failures int |
| 11 | want time.Duration |
| 12 | }{ |
| 13 | {0, 0}, |
| 14 | {1, 1 * time.Second}, |
| 15 | {2, 2 * time.Second}, |
| 16 | {3, 4 * time.Second}, |
| 17 | {4, 8 * time.Second}, |
| 18 | {5, 16 * time.Second}, |
| 19 | {6, 32 * time.Second}, |
| 20 | {7, 60 * time.Second}, // capped |
| 21 | {99, 60 * time.Second}, |
| 22 | } |
| 23 | for _, c := range cases { |
| 24 | if got := backoffDelay(c.failures); got != c.want { |
| 25 | t.Errorf("backoffDelay(%d) = %v, want %v", c.failures, got, c.want) |
| 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | // TestAttemptLimiterRejectsImmediateRetry is the integration check for |
| 31 | // the backoff machinery. The first call goes through; an immediate |
nothing calls this directly
no test coverage detected