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

Function TestUploadSingleShot_RetriesTooManyWriteOperations

cmd/put_test.go:209–236  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

207}
208
209func 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
238func testConfig() dropbox.Config {
239 return dropbox.Config{Token: "test-token"}

Callers

nothing calls this directly

Calls 3

stubRetrySleepFunction · 0.85
uploadWriteThrottleErrorFunction · 0.85
uploadSingleShotFunction · 0.85

Tested by

no test coverage detected