Skip to content

Commit b7ac5c7

Browse files
committed
test(connect): isolate claude-desktop config path on Windows
On Windows, ConfigPath ignores the homeDir override for claude-desktop and vscode (it reads %APPDATA%), so the no-key and with-key Claude Desktop bridge tests both wrote to the same real APPDATA\Claude path. The no-key test ran first and created the entry; the with-key test then hit `already_exists` (force=false) and never wrote the apikey, failing the assertion on the windows-amd64 runner. Pin %APPDATA% under the per-test temp dir in the test-service helpers, mirroring the existing %LOCALAPPDATA% line, so every client's config path is isolated per-test on Windows. No-op on macOS/Linux. Related MCP-2479
1 parent 0df7d44 commit b7ac5c7

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

internal/connect/connect_test.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ func TestConnect_OpenCode_AllowsTrailingCommaJSON(t *testing.T) {
5757
func testService(t *testing.T) (*Service, string) {
5858
t.Helper()
5959
homeDir := t.TempDir()
60-
// On Windows, ConfigPath("opencode", homeDir) reads %LOCALAPPDATA% from
61-
// the real environment and only falls back to homeDir when the env is
62-
// unset. Pin it under the test temp dir so the fallback path is the one
63-
// that fires regardless of CI runner state. No-op on macOS/Linux.
60+
// On Windows, ConfigPath reads %LOCALAPPDATA% (opencode) and %APPDATA%
61+
// (claude-desktop, vscode) from the real environment, ignoring homeDir,
62+
// and only falls back to homeDir when those env vars are unset. Pin both
63+
// under the test temp dir so every client's config path is isolated
64+
// per-test regardless of CI runner state. No-op on macOS/Linux.
6465
t.Setenv("LOCALAPPDATA", filepath.Join(homeDir, "AppData", "Local"))
66+
t.Setenv("APPDATA", filepath.Join(homeDir, "AppData", "Roaming"))
6567
svc := NewServiceWithHome("127.0.0.1:8080", "", homeDir)
6668
return svc, homeDir
6769
}
@@ -70,6 +72,7 @@ func testServiceWithKey(t *testing.T) (*Service, string) {
7072
t.Helper()
7173
homeDir := t.TempDir()
7274
t.Setenv("LOCALAPPDATA", filepath.Join(homeDir, "AppData", "Local"))
75+
t.Setenv("APPDATA", filepath.Join(homeDir, "AppData", "Roaming"))
7376
svc := NewServiceWithHome("127.0.0.1:8080", "test-key-123", homeDir)
7477
return svc, homeDir
7578
}

0 commit comments

Comments
 (0)