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

Function TestCpJSONMultipleSourcesOutputsMultipleResults

cmd/cp_test.go:240–265  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

238}
239
240func TestCpJSONMultipleSourcesOutputsMultipleResults(t *testing.T) {
241 stubFilesClient(t, &mockFilesClient{
242 copyV2Fn: func(arg *files.RelocationArg) (*files.RelocationResult, error) {
243 name := path.Base(arg.ToPath)
244 metadata := files.NewFileMetadata(name, "id:"+name, dropbox.DBXTime(time.Time{}), dropbox.DBXTime(time.Time{}), "rev", 1)
245 metadata.PathDisplay = arg.ToPath
246 metadata.PathLower = strings.ToLower(arg.ToPath)
247 return files.NewRelocationResult(metadata), nil
248 },
249 })
250
251 var stdout bytes.Buffer
252 cmd := newRelocationTestCommand(&stdout, nil)
253
254 if err := cp(cmd, []string{"/src/a.txt", "/src/b.txt", "/dest"}); err != nil {
255 t.Fatalf("cp error: %v", err)
256 }
257
258 got := decodeRelocationOutput(t, stdout.Bytes())
259 if len(got.Results) != 2 {
260 t.Fatalf("results = %d, want 2", len(got.Results))
261 }
262 if got.Results[0].Input.ToPath != "/dest/a.txt" || got.Results[1].Input.ToPath != "/dest/b.txt" {
263 t.Fatalf("results = %#v, want folder destinations", got.Results)
264 }
265}
266
267func TestCpJSONErrorUsesCommandStderr(t *testing.T) {
268 stubFilesClient(t, &mockFilesClient{

Callers

nothing calls this directly

Calls 4

stubFilesClientFunction · 0.85
newRelocationTestCommandFunction · 0.85
cpFunction · 0.85
decodeRelocationOutputFunction · 0.85

Tested by

no test coverage detected