(local string, remote string, outside string, filesToCheck testCaseList, foldersToCheck testCaseList)
| 653 | } |
| 654 | |
| 655 | func renameSomeTestFilesAndFolders(local string, remote string, outside string, filesToCheck testCaseList, foldersToCheck testCaseList) (testCaseList, testCaseList, error) { |
| 656 | for n, array := range []testCaseList{filesToCheck, foldersToCheck} { |
| 657 | for n, f := range array { |
| 658 | if !strings.Contains(f.path, "_Rename") { |
| 659 | continue |
| 660 | } |
| 661 | |
| 662 | fromParentDir, err := getParentDir(local, remote, outside, f.editLocation) |
| 663 | if err != nil { |
| 664 | return nil, nil, errors.Wrap(err, "get parent dir") |
| 665 | } |
| 666 | fromPath := path.Join(fromParentDir, f.path) |
| 667 | |
| 668 | var toParentDir string |
| 669 | if strings.HasSuffix(f.path, "_RenameToOutside") { |
| 670 | toParentDir = outside |
| 671 | } else if strings.Contains(f.path, "Local_Rename") { |
| 672 | toParentDir = local |
| 673 | } else if strings.Contains(f.path, "Remote_Rename") { |
| 674 | toParentDir = remote |
| 675 | } |
| 676 | |
| 677 | f.path = f.path + "After" |
| 678 | toPath := path.Join(toParentDir, f.path) |
| 679 | |
| 680 | err = os.Rename(fromPath, toPath) |
| 681 | if err != nil { |
| 682 | return nil, nil, errors.Wrap(err, "rename") |
| 683 | } |
| 684 | |
| 685 | if strings.HasSuffix(f.path, "_RenameToFullContextAfter") { |
| 686 | f.shouldExistInLocal = true |
| 687 | f.shouldExistInRemote = true |
| 688 | } else if strings.HasSuffix(f.path, "_RenameToNoDownloadAfter") { |
| 689 | f.shouldExistInRemote = true |
| 690 | f.shouldExistInLocal = f.editLocation == editInLocal |
| 691 | } else if strings.HasSuffix(f.path, "_RenameToNoUploadAfter") { |
| 692 | f.shouldExistInLocal = true |
| 693 | f.shouldExistInRemote = f.editLocation == editInRemote |
| 694 | } else if strings.HasSuffix(f.path, "_RenameToIgnoreAfter") { |
| 695 | f.shouldExistInLocal = f.editLocation == editInLocal |
| 696 | f.shouldExistInRemote = f.editLocation == editInRemote |
| 697 | } else if strings.HasSuffix(f.path, "_RenameToOutsideAfter") { |
| 698 | f.shouldExistInLocal = false |
| 699 | f.shouldExistInRemote = false |
| 700 | } else { |
| 701 | return nil, nil, errors.New("Bad rename suffix of " + f.path) |
| 702 | } |
| 703 | |
| 704 | array[n] = f |
| 705 | } |
| 706 | |
| 707 | if n == 0 { |
| 708 | filesToCheck = array |
| 709 | } else { |
| 710 | foldersToCheck = array |
| 711 | } |
| 712 | } |
no test coverage detected