(t *testing.T)
| 496 | } |
| 497 | |
| 498 | func 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 | |
| 531 | func TestCpCommandSupportsStructuredOutput(t *testing.T) { |
| 532 | if !commandSupportsStructuredOutput(cpCmd) { |
nothing calls this directly
no test coverage detected