From 75fa94f88c58da0eba9ab27644249d3eb5fe47bc Mon Sep 17 00:00:00 2001 From: Huan-zhaojun <111294954+Huan-zhaojun@users.noreply.github.com> Date: Wed, 5 Aug 2026 11:39:56 +0800 Subject: [PATCH] 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) --- backend/internal/infra/qualityguard/bootstrap_test.go | 5 ++++- backend/internal/transport/http/egress/handler_test.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/backend/internal/infra/qualityguard/bootstrap_test.go b/backend/internal/infra/qualityguard/bootstrap_test.go index 6e501f75..236d831c 100644 --- a/backend/internal/infra/qualityguard/bootstrap_test.go +++ b/backend/internal/infra/qualityguard/bootstrap_test.go @@ -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 diff --git a/backend/internal/transport/http/egress/handler_test.go b/backend/internal/transport/http/egress/handler_test.go index 9c88abfe..ad182620 100644 --- a/backend/internal/transport/http/egress/handler_test.go +++ b/backend/internal/transport/http/egress/handler_test.go @@ -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()) } }