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

Function TestDownloadToStdout_NoRetryAfterPartialOutput

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

Source from the content-addressed store, hash-verified

62}
63
64func TestDownloadToStdout_NoRetryAfterPartialOutput(t *testing.T) {
65 retryDelays := stubRetrySleep(t)
66 downloadCalls := 0
67
68 mock := &mockFilesClient{
69 downloadFn: func(arg *files.DownloadArg) (*files.FileMetadata, io.ReadCloser, error) {
70 downloadCalls++
71 meta := &files.FileMetadata{Size: 100}
72 return meta, &failingReadCloser{data: []byte("partial")}, nil
73 },
74 }
75
76 var buf bytes.Buffer
77 err := downloadToStdout(mock, "/file.txt", &buf)
78 if err == nil {
79 t.Fatal("expected error for partial output failure")
80 }
81 if !strings.Contains(err.Error(), "cannot retry") {
82 t.Errorf("error = %q, want mention of cannot retry", err.Error())
83 }
84 if downloadCalls != 1 {
85 t.Errorf("download calls = %d, want 1 (no second Download call after partial write)", downloadCalls)
86 }
87 if len(*retryDelays) != 0 {
88 t.Errorf("retry delays = %v, want no retry sleep after partial output", *retryDelays)
89 }
90}
91
92func TestDownloadToStdout_WriterEPIPEReturnsNil(t *testing.T) {
93 mock := &mockFilesClient{

Callers

nothing calls this directly

Calls 3

stubRetrySleepFunction · 0.85
downloadToStdoutFunction · 0.85
ErrorMethod · 0.45

Tested by

no test coverage detected