fix(test): use try/finally for guaranteed env restoration
This commit is contained in:
parent
5a2ab0095d
commit
9a2a6a695a
@ -91,14 +91,16 @@ describe("createBuiltinMcps", () => {
|
|||||||
const disabledMcps = ["websearch"]
|
const disabledMcps = ["websearch"]
|
||||||
const config = { websearch: { provider: "tavily" as const } }
|
const config = { websearch: { provider: "tavily" as const } }
|
||||||
|
|
||||||
// when
|
try {
|
||||||
const createMcps = () => createBuiltinMcps(disabledMcps, config)
|
// when
|
||||||
|
const createMcps = () => createBuiltinMcps(disabledMcps, config)
|
||||||
|
|
||||||
// then
|
// then
|
||||||
expect(createMcps).not.toThrow()
|
expect(createMcps).not.toThrow()
|
||||||
const result = createMcps()
|
const result = createMcps()
|
||||||
expect(result).not.toHaveProperty("websearch")
|
expect(result).not.toHaveProperty("websearch")
|
||||||
|
} finally {
|
||||||
if (originalTavilyKey) process.env.TAVILY_API_KEY = originalTavilyKey
|
if (originalTavilyKey) process.env.TAVILY_API_KEY = originalTavilyKey
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user