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

Function createTestFilesAndFolders

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

Source from the content-addressed store, hash-verified

557}
558
559func createTestFilesAndFolders(local string, remote string, outside string, filesToCheck testCaseList, foldersToCheck testCaseList) error {
560 for _, f := range foldersToCheck {
561 createLocation := f.editLocation
562 if f.isSymLink {
563 createLocation = editSymLinkDir
564 }
565
566 parentDir, err := getParentDir(local, remote, outside, createLocation)
567 if err != nil {
568 return errors.Wrap(err, "get parent dir")
569 }
570
571 err = os.MkdirAll(path.Join(parentDir, f.path), 0755)
572 if err != nil {
573 return errors.Wrap(err, "make dir")
574 }
575
576 if f.isSymLink {
577 symLinkParentDir, err := getParentDir(local, remote, outside, f.editLocation)
578 if err != nil {
579 return errors.Wrap(err, "get parent dir for symLink")
580 }
581 err = os.Symlink(path.Join(parentDir, f.path), path.Join(symLinkParentDir, f.path))
582 if err != nil {
583 return errors.Wrap(err, "make symLink")
584 }
585 }
586 }
587
588 for _, f := range filesToCheck {
589 createLocation := f.editLocation
590 if f.isSymLink {
591 createLocation = editSymLinkDir
592 }
593 parentDir, err := getParentDir(local, remote, outside, createLocation)
594 if err != nil {
595 return errors.Wrap(err, "get parent dir from "+f.path)
596 }
597
598 err = os.WriteFile(path.Join(parentDir, f.path), []byte(fileContents), 0666)
599 if err != nil {
600 return errors.Wrap(err, "write file")
601 }
602
603 if f.isSymLink {
604 symLinkParentDir, err := getParentDir(local, remote, outside, f.editLocation)
605 if err != nil {
606 return errors.Wrap(err, "get parent dir for symLink")
607 }
608 err = os.Symlink(path.Join(parentDir, f.path), path.Join(symLinkParentDir, f.path))
609 if err != nil {
610 return errors.Wrap(err, "make symLink")
611 }
612 }
613 }
614
615 return nil
616}

Callers 2

TestInitialSyncFunction · 0.85
TestNormalSyncFunction · 0.85

Calls 1

getParentDirFunction · 0.85

Tested by

no test coverage detected