(t *testing.T)
| 207 | } |
| 208 | |
| 209 | func TestUploadSingleShot_RetriesTooManyWriteOperations(t *testing.T) { |
| 210 | stubRetrySleep(t) |
| 211 | data := []byte("small file contents") |
| 212 | reader := bytes.NewReader(data) |
| 213 | uploadArg := &files.UploadArg{CommitInfo: *files.NewCommitInfo("/test.txt")} |
| 214 | |
| 215 | calls := 0 |
| 216 | mock := &mockFilesClient{ |
| 217 | uploadFn: func(arg *files.UploadArg, content io.Reader) (*files.FileMetadata, error) { |
| 218 | calls++ |
| 219 | if _, err := io.ReadAll(content); err != nil { |
| 220 | return nil, err |
| 221 | } |
| 222 | if calls == 1 { |
| 223 | return nil, uploadWriteThrottleError() |
| 224 | } |
| 225 | return &files.FileMetadata{}, nil |
| 226 | }, |
| 227 | } |
| 228 | |
| 229 | _, err := uploadSingleShot(mock, reader, uploadArg, int64(len(data)), nil) |
| 230 | if err != nil { |
| 231 | t.Errorf("expected nil error after write-throttle retry, got %v", err) |
| 232 | } |
| 233 | if calls != 2 { |
| 234 | t.Errorf("expected 2 calls, got %d", calls) |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | func testConfig() dropbox.Config { |
| 239 | return dropbox.Config{Token: "test-token"} |
nothing calls this directly
no test coverage detected