MCPcopy Index your code
hub / github.com/devspace-sh/devspace / renameSomeTestFilesAndFolders

Function renameSomeTestFilesAndFolders

pkg/devspace/sync/sync_test.go:655–715  ·  view source on GitHub ↗
(local string, remote string, outside string, filesToCheck testCaseList, foldersToCheck testCaseList)

Source from the content-addressed store, hash-verified

653}
654
655func 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 }

Callers 1

TestNormalSyncFunction · 0.85

Calls 1

getParentDirFunction · 0.85

Tested by

no test coverage detected