MCPcopy Create free account
hub / github.com/coder/coder / TestDelay

Function TestDelay

coderd/x/chatd/chatretry/chatretry_test.go:94–121  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

92}
93
94func TestDelay(t *testing.T) {
95 t.Parallel()
96
97 tests := []struct {
98 attempt int
99 want time.Duration
100 }{
101 {0, 1 * time.Second},
102 {1, 2 * time.Second},
103 {2, 4 * time.Second},
104 {3, 8 * time.Second},
105 {4, 16 * time.Second},
106 {5, 32 * time.Second},
107 {6, 60 * time.Second},
108 {10, 60 * time.Second},
109 {100, 60 * time.Second},
110 }
111
112 for _, tt := range tests {
113 t.Run(fmt.Sprintf("Attempt%d", tt.attempt), func(t *testing.T) {
114 t.Parallel()
115 got := chatretry.Delay(tt.attempt)
116 if got != tt.want {
117 t.Errorf("Delay(%d) = %v, want %v", tt.attempt, got, tt.want)
118 }
119 })
120 }
121}
122
123func TestRetry_SuccessOnFirstTry(t *testing.T) {
124 t.Parallel()

Callers

nothing calls this directly

Calls 3

DelayFunction · 0.92
RunMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected