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

Function TestDownloadToStdout_RetriesBeforeFirstByte

cmd/stdout_test.go:35–62  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

33}
34
35func TestDownloadToStdout_RetriesBeforeFirstByte(t *testing.T) {
36 stubRetrySleep(t)
37 content := "file content"
38 calls := 0
39
40 mock := &mockFilesClient{
41 downloadFn: func(arg *files.DownloadArg) (*files.FileMetadata, io.ReadCloser, error) {
42 calls++
43 if calls < 3 {
44 return nil, nil, dbxauth.ServerError{APIError: dropbox.APIError{ErrorSummary: "500"}}
45 }
46 meta := &files.FileMetadata{Size: uint64(len(content))}
47 return meta, io.NopCloser(strings.NewReader(content)), nil
48 },
49 }
50
51 var buf bytes.Buffer
52 err := downloadToStdout(mock, "/file.txt", &buf)
53 if err != nil {
54 t.Fatalf("unexpected error: %v", err)
55 }
56 if calls != 3 {
57 t.Errorf("calls = %d, want 3", calls)
58 }
59 if buf.String() != content {
60 t.Errorf("output = %q, want %q", buf.String(), content)
61 }
62}
63
64func TestDownloadToStdout_NoRetryAfterPartialOutput(t *testing.T) {
65 retryDelays := stubRetrySleep(t)

Callers

nothing calls this directly

Calls 2

stubRetrySleepFunction · 0.85
downloadToStdoutFunction · 0.85

Tested by

no test coverage detected