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

Function TestCpIfExistsSkipTextModeQuiet

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

Source from the content-addressed store, hash-verified

496}
497
498func TestCpIfExistsSkipTextModeQuiet(t *testing.T) {
499 stubFilesClient(t, &mockFilesClient{
500 getMetadataFn: func(arg *files.GetMetadataArg) (files.IsMetadata, error) {
501 return relocationTestFileMetadata(arg.Path, 8), nil
502 },
503 copyV2Fn: func(arg *files.RelocationArg) (*files.RelocationResult, error) {
504 t.Fatal("CopyV2 called for skipped destination")
505 return nil, nil
506 },
507 })
508
509 var stdout bytes.Buffer
510 var stderr bytes.Buffer
511 cmd := &cobra.Command{}
512 cmd.Flags().String(outputFlag, string(output.FormatText), "")
513 cmd.Flags().String("if-exists", relocationIfExistsFail, "")
514 if err := cmd.Flags().Set("if-exists", relocationIfExistsSkip); err != nil {
515 t.Fatal(err)
516 }
517 cmd.SetOut(&stdout)
518 cmd.SetErr(&stderr)
519
520 if err := cp(cmd, []string{"/src/file.txt", "/dest/file.txt"}); err != nil {
521 t.Fatalf("cp error: %v", err)
522 }
523 if stdout.String() != "" {
524 t.Fatalf("stdout = %q, want empty", stdout.String())
525 }
526 if stderr.String() != "" {
527 t.Fatalf("stderr = %q, want empty", stderr.String())
528 }
529}
530
531func TestCpCommandSupportsStructuredOutput(t *testing.T) {
532 if !commandSupportsStructuredOutput(cpCmd) {

Callers

nothing calls this directly

Calls 3

stubFilesClientFunction · 0.85
cpFunction · 0.85

Tested by

no test coverage detected