fix(test): skip POSIX permission assertions on Windows

Windows has no POSIX permission bits: os.WriteFile mode is ignored and
files report 0666-style permissions, so the 0600 assertions in the
qualityguard bootstrap and runtime-config tests always fail on Windows.
Skip them on Windows; POSIX behavior is unchanged.

(cherry picked from commit 0b9d0487b066472d33755c531b6f3f6a5c0da8ab)
This commit is contained in:
Huan-zhaojun committed 2026-08-05 12:01:53 +08:00
1 parent 725ecf0899
commit 75fa94f88c
2 files changed
+8 -2

No files matched your search

@@ -4,6 +4,7 @@ import (
"encoding/json"
"os"
"path/filepath"
"runtime"
"testing"
"time"
@@ -31,7 +32,9 @@ func TestPrepareWritesPrivateScopedBootstrap(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if info.Mode().Perm() != 0o600 {
// Windows has no POSIX permission bits: the os.WriteFile mode argument
// is ignored and files always report 0666-style permissions.
if runtime.GOOS != "windows" && info.Mode().Perm() != 0o600 {
t.Fatalf("mode = %o", info.Mode().Perm())
}
var payload bootstrapFile
@@ -5,6 +5,7 @@ import (
"errors"
"net/http/httptest"
"os"
"runtime"
"strings"
"testing"
"time"
@@ -120,7 +121,9 @@ func TestUpdateQualityGuardConfigWritesPrivateAtomicFile(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if info.Mode().Perm() != 0o600 {
// Windows has no POSIX permission bits: the os.WriteFile mode argument
// is ignored and files always report 0666-style permissions.
if runtime.GOOS != "windows" && info.Mode().Perm() != 0o600 {
t.Fatalf("runtime config mode = %o", info.Mode().Perm())
}
}