mirror of
https://github.com/YspCoder/clawgo.git
synced 2026-04-13 21:57:29 +08:00
29 lines
575 B
Go
29 lines
575 B
Go
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"runtime"
|
|
"testing"
|
|
)
|
|
|
|
func TestSaveConfigUsesOwnerOnlyPermissions(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
if runtime.GOOS == "windows" {
|
|
t.Skip("permission bits are not reliable on windows")
|
|
}
|
|
|
|
path := filepath.Join(t.TempDir(), "config.json")
|
|
if err := SaveConfig(path, DefaultConfig()); err != nil {
|
|
t.Fatalf("save config: %v", err)
|
|
}
|
|
info, err := os.Stat(path)
|
|
if err != nil {
|
|
t.Fatalf("stat config: %v", err)
|
|
}
|
|
if got := info.Mode().Perm(); got != 0o600 {
|
|
t.Fatalf("expected 0600 permissions, got %o", got)
|
|
}
|
|
}
|