Skip to content

Commit c97f84c

Browse files
committed
Fix Windows CI test failures
Set USERPROFILE alongside HOME in remote_test.go so os.UserHomeDir() resolves to the temp dir on Windows. Skip Unix file permission assertion in TestTokenFilePermissions on Windows where 0600 is not enforceable.
1 parent 73193b5 commit c97f84c

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

internal/config/remote_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func TestFetchRemoteImportRoot_RemoteFails_CachedCatalog(t *testing.T) {
7777
// Create a temp cache directory with a catalog
7878
tmpHome := t.TempDir()
7979
t.Setenv("HOME", tmpHome)
80+
t.Setenv("USERPROFILE", tmpHome) // Windows: os.UserHomeDir uses USERPROFILE
8081

8182
cacheDir := filepath.Join(tmpHome, ".cache", "apx", "catalogs", "acme", "apis")
8283
if err := os.MkdirAll(cacheDir, 0o755); err != nil {
@@ -106,6 +107,7 @@ func TestFetchRemoteImportRoot_AllFail(t *testing.T) {
106107
// No cached catalog either (temp HOME has nothing)
107108
tmpHome := t.TempDir()
108109
t.Setenv("HOME", tmpHome)
110+
t.Setenv("USERPROFILE", tmpHome) // Windows: os.UserHomeDir uses USERPROFILE
109111

110112
result := FetchRemoteImportRoot("acme", "apis")
111113
assert.Equal(t, "", result)
@@ -125,6 +127,7 @@ func TestFetchRemoteImportRoot_MalformedYAML(t *testing.T) {
125127

126128
tmpHome := t.TempDir()
127129
t.Setenv("HOME", tmpHome)
130+
t.Setenv("USERPROFILE", tmpHome) // Windows: os.UserHomeDir uses USERPROFILE
128131

129132
result := FetchRemoteImportRoot("acme", "apis")
130133
assert.Equal(t, "", result)
@@ -165,6 +168,7 @@ func TestFetchRemoteImportRoot_GHEndpoint(t *testing.T) {
165168

166169
tmpHome := t.TempDir()
167170
t.Setenv("HOME", tmpHome)
171+
t.Setenv("USERPROFILE", tmpHome) // Windows: os.UserHomeDir uses USERPROFILE
168172

169173
FetchRemoteImportRoot("myorg", "apis")
170174
assert.Equal(t, "repos/myorg/apis/contents/apx.yaml", capturedEndpoint)

pkg/githubauth/token_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package githubauth
33
import (
44
"os"
55
"path/filepath"
6+
"runtime"
67
"testing"
78
"time"
89

@@ -85,7 +86,10 @@ func TestTokenFilePermissions(t *testing.T) {
8586
info, err := os.Stat(p)
8687
require.NoError(t, err)
8788
// File should be readable/writable only by owner (0600).
88-
assert.Equal(t, os.FileMode(0600), info.Mode().Perm())
89+
// Windows does not support Unix file permission bits.
90+
if runtime.GOOS != "windows" {
91+
assert.Equal(t, os.FileMode(0600), info.Mode().Perm())
92+
}
8993
}
9094

9195
func TestReadWriteCache(t *testing.T) {

0 commit comments

Comments
 (0)