MCPcopy Index your code
hub / github.com/ZenNotes/zennotes / TestBackoffDelay

Function TestBackoffDelay

apps/server/internal/httpserver/limiter_test.go:8–28  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func 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

Callers

nothing calls this directly

Calls 1

backoffDelayFunction · 0.85

Tested by

no test coverage detected