(t *testing.T)
| 328 | } |
| 329 | |
| 330 | func 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 | |
| 355 | func TestCpIfExistsSkipExistingDestinationDoesNotCopy(t *testing.T) { |
| 356 | var copied bool |
nothing calls this directly
no test coverage detected