Merge pull request #3784 from matchai/chore/remove-redundant-env-restore
test: remove redundant local env restoration
This commit is contained in:
@@ -191,31 +191,18 @@ describe("claude-code-agent-loader", () => {
|
||||
describe("loadUserAgents", () => {
|
||||
test("returns empty object when pointed at dir without agents/", () => {
|
||||
const root = trackDir(mkdtempSync(join(tmpdir(), "agent-loader-test-")))
|
||||
// Temporarily set env var — best-effort in parallel test runner
|
||||
const prev = process.env.CLAUDE_CONFIG_DIR
|
||||
try {
|
||||
process.env.CLAUDE_CONFIG_DIR = root
|
||||
const result = loadUserAgents()
|
||||
expect(result).toEqual({})
|
||||
} finally {
|
||||
if (prev !== undefined) process.env.CLAUDE_CONFIG_DIR = prev
|
||||
else delete process.env.CLAUDE_CONFIG_DIR
|
||||
}
|
||||
process.env.CLAUDE_CONFIG_DIR = root
|
||||
const result = loadUserAgents()
|
||||
expect(result).toEqual({})
|
||||
})
|
||||
})
|
||||
|
||||
describe("loadOpencodeGlobalAgents", () => {
|
||||
test("returns empty object when pointed at dir without agents/", () => {
|
||||
const root = trackDir(mkdtempSync(join(tmpdir(), "agent-loader-test-")))
|
||||
const prev = process.env.OPENCODE_CONFIG_DIR
|
||||
try {
|
||||
process.env.OPENCODE_CONFIG_DIR = root
|
||||
const result = loadOpencodeGlobalAgents()
|
||||
expect(result).toEqual({})
|
||||
} finally {
|
||||
if (prev !== undefined) process.env.OPENCODE_CONFIG_DIR = prev
|
||||
else delete process.env.OPENCODE_CONFIG_DIR
|
||||
}
|
||||
process.env.OPENCODE_CONFIG_DIR = root
|
||||
const result = loadOpencodeGlobalAgents()
|
||||
expect(result).toEqual({})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -126,8 +126,6 @@ function createClientKey(info: SkillMcpClientInfo): string {
|
||||
return `${info.sessionID}:${info.skillName}:${info.serverName}`
|
||||
}
|
||||
|
||||
const ORIGINAL_ENV = { ...process.env }
|
||||
|
||||
beforeEach(() => {
|
||||
createdStdioTransports.length = 0
|
||||
createdHttpTransports.length = 0
|
||||
@@ -147,15 +145,6 @@ afterEach(async () => {
|
||||
}
|
||||
trackedStates.length = 0
|
||||
|
||||
for (const key of Object.keys(process.env)) {
|
||||
if (!(key in ORIGINAL_ENV)) {
|
||||
delete process.env[key]
|
||||
}
|
||||
}
|
||||
for (const [key, value] of Object.entries(ORIGINAL_ENV)) {
|
||||
process.env[key] = value
|
||||
}
|
||||
|
||||
setStdioClientDependenciesForTesting()
|
||||
setHttpClientDependenciesForTesting()
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user