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 config = { websearch: { provider: "tavily" as const } }
|
||||
|
||||
// when
|
||||
const createMcps = () => createBuiltinMcps(disabledMcps, config)
|
||||
try {
|
||||
// when
|
||||
const createMcps = () => createBuiltinMcps(disabledMcps, config)
|
||||
|
||||
// then
|
||||
expect(createMcps).not.toThrow()
|
||||
const result = createMcps()
|
||||
expect(result).not.toHaveProperty("websearch")
|
||||
|
||||
if (originalTavilyKey) process.env.TAVILY_API_KEY = originalTavilyKey
|
||||
// then
|
||||
expect(createMcps).not.toThrow()
|
||||
const result = createMcps()
|
||||
expect(result).not.toHaveProperty("websearch")
|
||||
} finally {
|
||||
if (originalTavilyKey) process.env.TAVILY_API_KEY = originalTavilyKey
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user