MCPcopy
hub / github.com/syncthing/syncthing / testSymlinks

Function testSymlinks

test/symlink_test.go:82–270  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

80}
81
82func testSymlinks(t *testing.T) {
83 log.Println("Cleaning...")
84 err := removeAll("s1", "s2", "h1/index*", "h2/index*")
85 if err != nil {
86 t.Fatal(err)
87 }
88
89 log.Println("Generating files...")
90 err = generateFiles("s1", 100, 20, "../LICENSE")
91 if err != nil {
92 t.Fatal(err)
93 }
94
95 // A file that we will replace with a symlink later
96
97 fd, err := os.Create("s1/fileToReplace")
98 if err != nil {
99 t.Fatal(err)
100 }
101 fd.Close()
102
103 // A directory that we will replace with a symlink later
104
105 err = os.Mkdir("s1/dirToReplace", 0o755)
106 if err != nil {
107 t.Fatal(err)
108 }
109
110 // A file and a symlink to that file
111
112 fd, err = os.Create("s1/file")
113 if err != nil {
114 t.Fatal(err)
115 }
116 fd.Close()
117 err = os.Symlink("file", "s1/fileLink")
118 if err != nil {
119 log.Fatal(err)
120 }
121
122 // A directory and a symlink to that directory
123
124 err = os.Mkdir("s1/dir", 0o755)
125 if err != nil {
126 t.Fatal(err)
127 }
128 err = os.Symlink("dir", "s1/dirLink")
129 if err != nil {
130 log.Fatal(err)
131 }
132
133 // A link to something in the repo that does not exist
134
135 err = os.Symlink("does/not/exist", "s1/noneLink")
136 if err != nil {
137 log.Fatal(err)
138 }
139

Callers 3

TestSymlinksFunction · 0.85

Calls 14

AwaitSyncFunction · 0.92
removeAllFunction · 0.85
startInstanceFunction · 0.85
checkedStopFunction · 0.85
FatalMethod · 0.80
ResumeAllMethod · 0.80
RescanMethod · 0.80
generateFilesFunction · 0.70
compareDirectoriesFunction · 0.70
CreateMethod · 0.65
CloseMethod · 0.65
MkdirMethod · 0.65

Tested by

no test coverage detected