]> ruderich.org/simon Gitweb - safcm/safcm.git/commitdiff
config: tests: replace FullPermToFileMode() with fs constants
authorSimon Ruderich <simon@ruderich.org>
Sun, 9 May 2021 10:29:08 +0000 (12:29 +0200)
committerSimon Ruderich <simon@ruderich.org>
Sun, 9 May 2021 13:15:43 +0000 (15:15 +0200)
FullPermToFileMode() is necessary in a few places but the tests should
use the common way in Go to set permissions. This is less confusing for
the reader.

cmd/safcm/config/files_test.go

index cc963c94a232ea3df776c11b45c76500f06ce110..7ad12d62f32c6516efa2736e770924dfdab2ce42 100644 (file)
@@ -27,8 +27,8 @@ import (
        "ruderich.org/simon/safcm/testutil"
 )
 
-func chmod(name string, perm int) {
-       err := os.Chmod(name, FullPermToFileMode(perm))
+func chmod(name string, mode fs.FileMode) {
+       err := os.Chmod(name, mode)
        if err != nil {
                panic(err)
        }
@@ -55,7 +55,7 @@ func TestLoadFiles(t *testing.T) {
        chmod("files-invalid-perm-dir/files/etc/", 0755)
        chmod("files-invalid-perm-dir/files/etc/resolv.conf", 0644)
        chmod("files-invalid-perm-dir-setgid/files", 0755)
-       chmod("files-invalid-perm-dir-setgid/files/etc/", 02755)
+       chmod("files-invalid-perm-dir-setgid/files/etc/", 0755|fs.ModeSetgid)
        chmod("files-invalid-perm-dir-setgid/files/etc/resolv.conf", 0644)
        chmod("files-invalid-perm-file/files", 0755)
        chmod("files-invalid-perm-file/files/etc/", 0755)
@@ -66,7 +66,8 @@ func TestLoadFiles(t *testing.T) {
        if !skipInvalidSticky {
                chmod("files-invalid-perm-file-sticky/files", 0755)
                chmod("files-invalid-perm-file-sticky/files/etc", 0755)
-               chmod("files-invalid-perm-file-sticky/files/etc/resolv.conf", 01644)
+               chmod("files-invalid-perm-file-sticky/files/etc/resolv.conf",
+                       0644|fs.ModeSticky)
        }
 
        ft.CreateFifo("files-invalid-type/files/invalid", 0644)