Skip to content

Commit 90ca051

Browse files
committed
fix: skip file permission assertions on Windows in setup tests
Windows does not enforce Unix-style file permission bits, so os.WriteFile(..., 0600) results in 0666 on Windows. Guard the three os.FileMode(0600) assertions with runtime.GOOS != "windows" to fix CI failures on the Windows runner.
1 parent afbc42a commit 90ca051

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

internal/github/setup_test.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"net/http"
66
"os"
77
"path/filepath"
8+
"runtime"
89
"strings"
910
"testing"
1011
"time"
@@ -37,11 +38,13 @@ func TestCachePEM_CopiesAndCaches(t *testing.T) {
3738
require.NoError(t, err)
3839
assert.Equal(t, "fake-pem-data", contents)
3940

40-
// Verify the cached file exists with 0600
41+
// Verify the cached file exists with 0600 (skip on Windows where perms aren't enforced)
4142
cachedPath := filepath.Join(cacheDir, "testorg-app.pem")
4243
info, err := os.Stat(cachedPath)
4344
require.NoError(t, err)
44-
assert.Equal(t, os.FileMode(0600), info.Mode().Perm())
45+
if runtime.GOOS != "windows" {
46+
assert.Equal(t, os.FileMode(0600), info.Mode().Perm())
47+
}
4548

4649
// Second call should use cache (even with empty pemPath)
4750
contents2, err := CachePEM("testorg", "")
@@ -171,10 +174,12 @@ func TestCacheAndGetAppID(t *testing.T) {
171174
// Read it back
172175
assert.Equal(t, "12345", GetCachedAppID("acme"))
173176

174-
// File has 0600 perms
177+
// File has 0600 perms (skip on Windows where perms aren't enforced)
175178
info, err := os.Stat(filepath.Join(tmp, "acme-app-id"))
176179
require.NoError(t, err)
177-
assert.Equal(t, os.FileMode(0600), info.Mode().Perm())
180+
if runtime.GOOS != "windows" {
181+
assert.Equal(t, os.FileMode(0600), info.Mode().Perm())
182+
}
178183
}
179184

180185
// ---------------------------------------------------------------------------
@@ -195,7 +200,9 @@ func TestCachePEMFromContents(t *testing.T) {
195200

196201
info, err := os.Stat(filepath.Join(tmp, "acme-app.pem"))
197202
require.NoError(t, err)
198-
assert.Equal(t, os.FileMode(0600), info.Mode().Perm())
203+
if runtime.GOOS != "windows" {
204+
assert.Equal(t, os.FileMode(0600), info.Mode().Perm())
205+
}
199206
}
200207

201208
// ---------------------------------------------------------------------------

0 commit comments

Comments
 (0)