fix(test): set USERPROFILE for Windows in CONFIG_PATH test

The CONFIG_PATH test sets HOME to isolate the test environment, but on
Windows os.homedir() uses USERPROFILE instead. This caused the test to
use the global test home directory rather than the test-local temp dir,
resulting in path mismatches.

Fixes checks-windows CI failure introduced in e2c437e.
This commit is contained in:
Dominic 2026-01-27 19:31:27 -06:00
parent afd57c7e23
commit e34fda559e

View File

@ -69,6 +69,7 @@ describe("state + config path candidates", () => {
it("CONFIG_PATH prefers existing legacy filename when present", async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), "moltbot-config-"));
const previousHome = process.env.HOME;
const previousUserProfile = process.env.USERPROFILE;
const previousMoltbotConfig = process.env.MOLTBOT_CONFIG_PATH;
const previousClawdbotConfig = process.env.CLAWDBOT_CONFIG_PATH;
const previousMoltbotState = process.env.MOLTBOT_STATE_DIR;
@ -80,6 +81,7 @@ describe("state + config path candidates", () => {
await fs.writeFile(legacyPath, "{}", "utf-8");
process.env.HOME = root;
process.env.USERPROFILE = root;
delete process.env.MOLTBOT_CONFIG_PATH;
delete process.env.CLAWDBOT_CONFIG_PATH;
delete process.env.MOLTBOT_STATE_DIR;
@ -94,6 +96,11 @@ describe("state + config path candidates", () => {
} else {
process.env.HOME = previousHome;
}
if (previousUserProfile === undefined) {
delete process.env.USERPROFILE;
} else {
process.env.USERPROFILE = previousUserProfile;
}
if (previousMoltbotConfig === undefined) delete process.env.MOLTBOT_CONFIG_PATH;
else process.env.MOLTBOT_CONFIG_PATH = previousMoltbotConfig;
if (previousClawdbotConfig === undefined) delete process.env.CLAWDBOT_CONFIG_PATH;