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

Function TestCpIfExistsFailCallsCopy

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

Source from the content-addressed store, hash-verified

328}
329
330func TestCpIfExistsFailCallsCopy(t *testing.T) {
331 var copied []*files.RelocationArg
332 stubFilesClient(t, &mockFilesClient{
333 getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) {
334 return nil, relocationTestGetMetadataNotFoundError()
335 },
336 copyV2Fn: func(arg *files.RelocationArg) (*files.RelocationResult, error) {
337 copied = append(copied, arg)
338 return files.NewRelocationResult(relocationTestFileMetadata(arg.ToPath, 1)), nil
339 },
340 })
341
342 var stdout bytes.Buffer
343 cmd := newRelocationTestCommand(&stdout, nil)
344 if err := cmd.Flags().Set("if-exists", relocationIfExistsFail); err != nil {
345 t.Fatal(err)
346 }
347 if err := cp(cmd, []string{"/src/file.txt", "/dest/file.txt"}); err != nil {
348 t.Fatalf("cp error: %v", err)
349 }
350 if len(copied) != 1 {
351 t.Fatalf("copied = %d, want 1", len(copied))
352 }
353}
354
355func TestCpIfExistsSkipExistingDestinationDoesNotCopy(t *testing.T) {
356 var copied bool

Callers

nothing calls this directly

Calls 5

stubFilesClientFunction · 0.85
newRelocationTestCommandFunction · 0.85
cpFunction · 0.85

Tested by

no test coverage detected