From 902f4dd358b7b3f27faccba2e40a04abc760546f Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sun, 9 May 2021 12:29:08 +0200 Subject: [PATCH] config: tests: replace FullPermToFileMode() with fs constants 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 | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cmd/safcm/config/files_test.go b/cmd/safcm/config/files_test.go index cc963c9..7ad12d6 100644 --- a/cmd/safcm/config/files_test.go +++ b/cmd/safcm/config/files_test.go @@ -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) -- 2.45.2