adjust tests

adjust-instructions-logic
Aiden Cline 2026-02-01 12:52:23 -06:00
parent f2e1dbda16
commit 463bd05ce5
1 changed files with 12 additions and 14 deletions

View File

@ -6,14 +6,6 @@ import { InstructionPrompt } from "../../src/session/instruction"
import { Instance } from "../../src/project/instance" import { Instance } from "../../src/project/instance"
import { tmpdir } from "../fixture/fixture" import { tmpdir } from "../fixture/fixture"
const restore = (key: string, value: string | undefined) => {
if (value === undefined) {
delete process.env[key]
return
}
process.env[key] = value
}
describe("InstructionPrompt.resolve", () => { describe("InstructionPrompt.resolve", () => {
test("returns empty when AGENTS.md is at project root (already in systemPaths)", async () => { test("returns empty when AGENTS.md is at project root (already in systemPaths)", async () => {
await using tmp = await tmpdir({ await using tmp = await tmpdir({
@ -96,9 +88,12 @@ describe("InstructionPrompt.systemPaths", () => {
}) })
} finally { } finally {
await fs.rm(path.join(Global.Path.config, "AGENTS.md"), { force: true }) await fs.rm(path.join(Global.Path.config, "AGENTS.md"), { force: true })
restore("OPENCODE_TEST_HOME", homeValue) if (homeValue === undefined) delete process.env["OPENCODE_TEST_HOME"]
restore("OPENCODE_CONFIG_DIR", configValue) if (homeValue !== undefined) process.env["OPENCODE_TEST_HOME"] = homeValue
restore("OPENCODE_DISABLE_CLAUDE_CODE_PROMPT", disableValue) if (configValue === undefined) delete process.env["OPENCODE_CONFIG_DIR"]
if (configValue !== undefined) process.env["OPENCODE_CONFIG_DIR"] = configValue
if (disableValue === undefined) delete process.env["OPENCODE_DISABLE_CLAUDE_CODE_PROMPT"]
if (disableValue !== undefined) process.env["OPENCODE_DISABLE_CLAUDE_CODE_PROMPT"] = disableValue
} }
}) })
@ -133,9 +128,12 @@ describe("InstructionPrompt.systemPaths", () => {
}) })
} finally { } finally {
await fs.rm(path.join(Global.Path.config, "AGENTS.md"), { force: true }) await fs.rm(path.join(Global.Path.config, "AGENTS.md"), { force: true })
restore("OPENCODE_TEST_HOME", homeValue) if (homeValue === undefined) delete process.env["OPENCODE_TEST_HOME"]
restore("OPENCODE_CONFIG_DIR", configValue) if (homeValue !== undefined) process.env["OPENCODE_TEST_HOME"] = homeValue
restore("OPENCODE_DISABLE_CLAUDE_CODE_PROMPT", disableValue) if (configValue === undefined) delete process.env["OPENCODE_CONFIG_DIR"]
if (configValue !== undefined) process.env["OPENCODE_CONFIG_DIR"] = configValue
if (disableValue === undefined) delete process.env["OPENCODE_DISABLE_CLAUDE_CODE_PROMPT"]
if (disableValue !== undefined) process.env["OPENCODE_DISABLE_CLAUDE_CODE_PROMPT"] = disableValue
} }
}) })
}) })