Skip to content

Commit c426a90

Browse files
committed
fix(test): make the auth-detect fixtures platform-neutral
Both new suites assumed POSIX: one compared against a literal forward-slash path that join() builds with backslashes on Windows, and the other passed a hardcoded /tmp to mkdtempSync, which does not exist there. Six failures on windows-latest, none on macOS or Linux.
1 parent 9d1bb14 commit c426a90

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

tests/claude-auth-detect.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ test("claudeConfigDir honours CLAUDE_CONFIG_DIR", () => {
121121
// `os.homedir()` reads the OS user database and IGNORES a reassigned HOME, so a probe
122122
// against an isolated profile would silently read the real user's files instead.
123123
test("claudeConfigDir follows a reassigned HOME instead of the OS user database", () => {
124-
expect(claudeConfigDir({ HOME: "/tmp/fake-home" })).toBe("/tmp/fake-home/.claude");
125-
expect(claudeConfigDir({ USERPROFILE: "C:\\fake" })).toContain(".claude");
124+
// `join` uses the platform separator, so compare against a joined path, not a literal.
125+
expect(claudeConfigDir({ HOME: join("/tmp", "fake-home") })).toBe(join("/tmp", "fake-home", ".claude"));
126+
expect(claudeConfigDir({ USERPROFILE: join("/tmp", "fake-profile") })).toBe(join("/tmp", "fake-profile", ".claude"));
126127
});
127128

128129
// Same reason for ~/.claude.json: under CLAUDE_CONFIG_DIR it is that dir's SIBLING.

tests/claude-system-env-auto.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { afterEach, beforeEach, expect, spyOn, test } from "bun:test";
22
import * as childProcess from "node:child_process";
33
import * as fs from "node:fs";
4+
import { tmpdir } from "node:os";
5+
import { join } from "node:path";
46
import { injectSystemEnv } from "../src/server/system-env";
57
import { PROXY_MARKER } from "../src/claude/auth-detect";
68
import type { OcxConfig } from "../src/types";
@@ -52,7 +54,7 @@ beforeEach(() => {
5254
delete process.env.ANTHROPIC_API_KEY;
5355
delete process.env.ANTHROPIC_AUTH_TOKEN;
5456
// An empty profile dir + a HOME with no ~/.claude.json = detection "absent".
55-
const empty = fs.mkdtempSync("/tmp/ocx-sysenv-");
57+
const empty = fs.mkdtempSync(join(tmpdir(), "ocx-sysenv-"));
5658
process.env.CLAUDE_CONFIG_DIR = empty;
5759
process.env.HOME = empty;
5860

0 commit comments

Comments
 (0)