MCPcopy Create free account
hub / github.com/dropbox/dbxcli / TestRetryWithBackoff_TransientThenSuccess

Function TestRetryWithBackoff_TransientThenSuccess

cmd/retry_test.go:153–178  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

151}
152
153func TestRetryWithBackoff_TransientThenSuccess(t *testing.T) {
154 delays := stubRetrySleep(t)
155 calls := 0
156 err := retryWithBackoff(func() error {
157 calls++
158 if calls < 3 {
159 return auth.ServerError{APIError: dropbox.APIError{ErrorSummary: "500"}}
160 }
161 return nil
162 })
163 if err != nil {
164 t.Errorf("expected nil error, got %v", err)
165 }
166 if calls != 3 {
167 t.Errorf("expected 3 calls, got %d", calls)
168 }
169 wantDelays := []time.Duration{initialBackoff, 2 * initialBackoff}
170 if len(*delays) != len(wantDelays) {
171 t.Fatalf("expected %d sleeps, got %d", len(wantDelays), len(*delays))
172 }
173 for i, want := range wantDelays {
174 if (*delays)[i] != want {
175 t.Errorf("sleep %d = %v, want %v", i, (*delays)[i], want)
176 }
177 }
178}
179
180func TestRetryWithBackoff_RateLimitUsesRetryAfter(t *testing.T) {
181 delays := stubRetrySleep(t)

Callers

nothing calls this directly

Calls 2

stubRetrySleepFunction · 0.85
retryWithBackoffFunction · 0.85

Tested by

no test coverage detected