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

Function TestGetDstAppendsToDirectory

cmd/get_test.go:141–169  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

139}
140
141func TestGetDstAppendsToDirectory(t *testing.T) {
142 tmpDir := t.TempDir()
143
144 content := "pdf content"
145 mock := &mockFilesClient{
146 downloadFn: func(arg *files.DownloadArg) (*files.FileMetadata, io.ReadCloser, error) {
147 if arg.Path != "/remote/doc.pdf" {
148 t.Errorf("download path = %q, want %q", arg.Path, "/remote/doc.pdf")
149 }
150 meta := &files.FileMetadata{
151 Metadata: files.Metadata{PathDisplay: "/remote/doc.pdf"},
152 Size: uint64(len(content)),
153 }
154 return meta, io.NopCloser(strings.NewReader(content)), nil
155 },
156 }
157
158 err := getWithClient(mock, []string{"/remote/doc.pdf", tmpDir})
159 if err != nil {
160 t.Fatalf("expected nil error, got %v", err)
161 }
162 got, err := os.ReadFile(filepath.Join(tmpDir, "doc.pdf"))
163 if err != nil {
164 t.Fatalf("failed to read downloaded file: %v", err)
165 }
166 if string(got) != content {
167 t.Errorf("got %q, want %q", string(got), content)
168 }
169}
170
171func TestGetDownloadWithRetry(t *testing.T) {
172 stubRetrySleep(t)

Callers

nothing calls this directly

Calls 1

getWithClientFunction · 0.85

Tested by

no test coverage detected