MCPcopy
hub / github.com/syncthing/syncthing / TestChmodFile

Function TestChmodFile

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

Source from the content-addressed store, hash-verified

31}
32
33func TestChmodFile(t *testing.T) {
34 fs, dir := setup(t)
35 path := filepath.Join(dir, "file")
36
37 defer os.Chmod(path, 0o666)
38
39 fd, err := os.Create(path)
40 if err != nil {
41 t.Error(err)
42 }
43 fd.Close()
44
45 if err := os.Chmod(path, 0o666); err != nil {
46 t.Error(err)
47 }
48
49 if stat, err := os.Stat(path); err != nil || stat.Mode()&os.ModePerm != 0o666 {
50 t.Errorf("wrong perm: %t %#o", err == nil, stat.Mode()&os.ModePerm)
51 }
52
53 if err := fs.Chmod("file", 0o444); err != nil {
54 t.Error(err)
55 }
56
57 if stat, err := os.Stat(path); err != nil || stat.Mode()&os.ModePerm != 0o444 {
58 t.Errorf("wrong perm: %t %#o", err == nil, stat.Mode()&os.ModePerm)
59 }
60}
61
62func TestChownFile(t *testing.T) {
63 if build.IsWindows {

Callers

nothing calls this directly

Calls 7

setupFunction · 0.85
ChmodMethod · 0.65
CreateMethod · 0.65
ErrorMethod · 0.65
CloseMethod · 0.65
StatMethod · 0.65
ModeMethod · 0.65

Tested by

no test coverage detected