MCPcopy Index your code
hub / github.com/syncthing/syncthing / TestChmodDir

Function TestChmodDir

lib/fs/basicfs_test.go:109–139  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

107}
108
109func TestChmodDir(t *testing.T) {
110 fs, dir := setup(t)
111 path := filepath.Join(dir, "dir")
112
113 mode := os.FileMode(0o755)
114 if build.IsWindows {
115 mode = os.FileMode(0o777)
116 }
117
118 defer os.Chmod(path, mode)
119
120 if err := os.Mkdir(path, mode); err != nil {
121 t.Error(err)
122 }
123 // On UNIX, Mkdir will subtract the umask, so force desired mode explicitly
124 if err := os.Chmod(path, mode); err != nil {
125 t.Error(err)
126 }
127
128 if stat, err := os.Stat(path); err != nil || stat.Mode()&os.ModePerm != mode {
129 t.Errorf("wrong perm: %t %#o", err == nil, stat.Mode()&os.ModePerm)
130 }
131
132 if err := fs.Chmod("dir", 0o555); err != nil {
133 t.Error(err)
134 }
135
136 if stat, err := os.Stat(path); err != nil || stat.Mode()&os.ModePerm != 0o555 {
137 t.Errorf("wrong perm: %t %#o", err == nil, stat.Mode()&os.ModePerm)
138 }
139}
140
141func TestChtimes(t *testing.T) {
142 fs, dir := setup(t)

Callers

nothing calls this directly

Calls 6

setupFunction · 0.85
ChmodMethod · 0.65
MkdirMethod · 0.65
ErrorMethod · 0.65
StatMethod · 0.65
ModeMethod · 0.65

Tested by

no test coverage detected