tests: add chmod test

Makes sure we don't add regressions when fixing
https://github.com/rfjakob/gocryptfs/issues/259
This commit is contained in:
Jakob Unterwurzacher 2018-09-08 17:00:23 +02:00
parent 21b5fae0e6
commit bc14f8dcb6
1 changed files with 22 additions and 0 deletions

View File

@ -883,3 +883,25 @@ func TestMagicNames(t *testing.T) {
}
}
}
// Test that chmod works correctly
func TestChmod(t *testing.T) {
path := test_helpers.DefaultPlainDir + "/" + t.Name()
file, err := os.Create(path)
if err != nil {
t.Fatal(err)
}
file.Close()
modes := []os.FileMode{0777, 0707, 0606, 0666, 0444, 0000, 0111, 0123, 0321}
for _, modeWant := range modes {
os.Chmod(path, modeWant)
fi, err := os.Stat(path)
if err != nil {
t.Fatal(err)
}
modeHave := fi.Mode()
if modeHave != modeWant {
t.Errorf("modeHave %#o != modeWant %#o", modeHave, modeWant)
}
}
}