MCPcopy
hub / github.com/syncthing/syncthing / TestInWritableDirWindowsRename

Function TestInWritableDirWindowsRename

lib/model/utils_test.go:130–176  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

128}
129
130func TestInWritableDirWindowsRename(t *testing.T) {
131 if !build.IsWindows {
132 t.Skipf("Tests not required")
133 return
134 }
135
136 fs := fs.NewFilesystem(fs.FilesystemTypeFake, rand.String(32))
137
138 create := func(name string) error {
139 fd, err := fs.Create(name)
140 if err != nil {
141 return err
142 }
143 fd.Close()
144 return nil
145 }
146
147 fs.Mkdir("testdata", 0o700)
148
149 fs.Mkdir("testdata/windows", 0o500)
150 fs.Mkdir("testdata/windows/ro", 0o500)
151 create("testdata/windows/ro/readonly")
152 fs.Chmod("testdata/windows/ro/readonly", 0o500)
153
154 for _, path := range []string{"testdata/windows/ro/readonly", "testdata/windows/ro", "testdata/windows"} {
155 err := fs.Rename(path, path+"new")
156 if err == nil {
157 t.Skipf("seem like this test doesn't work here")
158 return
159 }
160 }
161
162 rename := func(path string) error {
163 return fs.Rename(path, path+"new")
164 }
165
166 for _, path := range []string{"testdata/windows/ro/readonly", "testdata/windows/ro", "testdata/windows"} {
167 err := inWritableDir(rename, fs, path, false)
168 if err != nil {
169 t.Errorf("Unexpected error %s: %s", path, err)
170 }
171 _, err = fs.Stat(path + "new")
172 if err != nil {
173 t.Errorf("Unexpected error %s: %s", path, err)
174 }
175 }
176}

Callers

nothing calls this directly

Calls 8

CreateMethod · 0.95
MkdirMethod · 0.95
ChmodMethod · 0.95
RenameMethod · 0.95
StatMethod · 0.95
StringFunction · 0.92
inWritableDirFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected