(t *testing.T)
| 35 | } |
| 36 | |
| 37 | func TestUploadOneChunk_RetryOnServerError(t *testing.T) { |
| 38 | stubRetrySleep(t) |
| 39 | calls := 0 |
| 40 | mock := &mockFilesClient{ |
| 41 | uploadSessionAppendV2Fn: func(arg *files.UploadSessionAppendArg, content io.Reader) error { |
| 42 | calls++ |
| 43 | if calls < 3 { |
| 44 | return dbxauth.ServerError{APIError: dropbox.APIError{ErrorSummary: "500"}} |
| 45 | } |
| 46 | return nil |
| 47 | }, |
| 48 | } |
| 49 | |
| 50 | cursor := files.NewUploadSessionCursor("session123", 0) |
| 51 | args := files.NewUploadSessionAppendArg(cursor) |
| 52 | data := []byte("hello chunk") |
| 53 | |
| 54 | err := uploadOneChunk(mock, args, data) |
| 55 | if err != nil { |
| 56 | t.Errorf("expected nil error after retry, got %v", err) |
| 57 | } |
| 58 | if calls != 3 { |
| 59 | t.Errorf("expected 3 calls, got %d", calls) |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | func TestUploadOneChunk_RateLimitUsesSingleRetryAfterDelay(t *testing.T) { |
| 64 | delays := stubRetrySleep(t) |
nothing calls this directly
no test coverage detected