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

Function TestUploadOneChunk_RetryOnServerError

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

Source from the content-addressed store, hash-verified

35}
36
37func 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
63func TestUploadOneChunk_RateLimitUsesSingleRetryAfterDelay(t *testing.T) {
64 delays := stubRetrySleep(t)

Callers

nothing calls this directly

Calls 2

stubRetrySleepFunction · 0.85
uploadOneChunkFunction · 0.85

Tested by

no test coverage detected