fix: skip permission tests when running as root (CI/Docker)
All checks were successful
Security Scan / security (push) Successful in 15s
Test / test (push) Successful in 3m16s

Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
Snider 2026-02-23 07:04:58 +00:00
parent 3bcb8ff741
commit ade9766d65

View file

@ -569,6 +569,9 @@ func TestPersistAndLoad(t *testing.T) {
})
t.Run("load from unreadable file returns error", func(t *testing.T) {
if os.Getuid() == 0 {
t.Skip("chmod 000 does not restrict root")
}
tmpDir := t.TempDir()
path := filepath.Join(tmpDir, "unreadable.yaml")
require.NoError(t, os.WriteFile(path, []byte("quotas: {}"), 0644))
@ -600,6 +603,9 @@ func TestPersistAndLoad(t *testing.T) {
})
t.Run("persist to unwritable directory returns error", func(t *testing.T) {
if os.Getuid() == 0 {
t.Skip("chmod 0555 does not restrict root")
}
tmpDir := t.TempDir()
unwritable := filepath.Join(tmpDir, "readonly")
require.NoError(t, os.MkdirAll(unwritable, 0555))