MCPcopy
hub / github.com/perkeep/perkeep / TestSymlink

Function TestSymlink

pkg/fs/fs_test.go:637–676  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

635}
636
637func TestSymlink(t *testing.T) {
638 condSkip(t)
639 // Do it all once, unmount, re-mount and then check again.
640 // TODO(bradfitz): do this same pattern (unmount and remount) in the other tests.
641 var suffix string
642 var link string
643 const target = "../../some-target" // arbitrary string. some-target is fake.
644 check := func() {
645 fi, err := os.Lstat(link)
646 if err != nil {
647 t.Fatalf("Stat: %v", err)
648 }
649 if fi.Mode()&os.ModeSymlink == 0 {
650 t.Errorf("Mode = %v; want Symlink bit set", fi.Mode())
651 }
652 got, err := os.Readlink(link)
653 if err != nil {
654 t.Fatalf("Readlink: %v", err)
655 }
656 if got != target {
657 t.Errorf("ReadLink = %q; want %q", got, target)
658 }
659 }
660 inEmptyMutDir(t, func(env *mountEnv, rootDir string) {
661 // Save for second test:
662 link = filepath.Join(rootDir, "some-link")
663 suffix = strings.TrimPrefix(link, env.mountPoint)
664
665 if err := os.Symlink(target, link); err != nil {
666 t.Fatalf("Symlink: %v", err)
667 }
668 t.Logf("Checking in first process...")
669 check()
670 })
671 pkmountTest(t, func(env *mountEnv) {
672 t.Logf("Checking in second process...")
673 link = env.mountPoint + suffix
674 check()
675 })
676}
677
678func TestFinderCopy(t *testing.T) {
679 if runtime.GOOS != "darwin" {

Callers

nothing calls this directly

Calls 10

condSkipFunction · 0.85
inEmptyMutDirFunction · 0.85
pkmountTestFunction · 0.85
ModeMethod · 0.80
LogfMethod · 0.80
LstatMethod · 0.65
FatalfMethod · 0.65
SymlinkMethod · 0.65
checkFunction · 0.50
ReadlinkMethod · 0.45

Tested by

no test coverage detected