Files
wehub-resource-sync ead81af521
Deploy to GitHub Pages / deploy (push) Failing after 0s
CI / go (push) Has been cancelled
CI / build (darwin, macos-14) (push) Has been cancelled
CI / build (windows, windows-2025) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:31:13 +08:00

25 lines
496 B
Go

package fileutil
import (
"os"
"path/filepath"
"testing"
)
func TestWriteFileAtomicPreservesStricterMode(t *testing.T) {
path := filepath.Join(t.TempDir(), "secret")
if err := os.WriteFile(path, []byte("old"), 0o400); err != nil {
t.Fatal(err)
}
if err := WriteFileAtomic(path, []byte("new"), 0o600); err != nil {
t.Fatal(err)
}
info, err := os.Stat(path)
if err != nil {
t.Fatal(err)
}
if got := info.Mode().Perm(); got != 0o400 {
t.Errorf("mode = %o, want 400", got)
}
}