mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 10:41:37 +00:00
refactor(test): standardize env helpers across suites
This commit is contained in:
@@ -40,6 +40,20 @@ describe("env test utils", () => {
|
||||
expect(process.env[key]).toBe(prev);
|
||||
});
|
||||
|
||||
it("withEnv restores values when callback throws", () => {
|
||||
const key = "OPENCLAW_ENV_TEST_SYNC_THROW";
|
||||
const prev = process.env[key];
|
||||
|
||||
expect(() =>
|
||||
withEnv({ [key]: "inside" }, () => {
|
||||
expect(process.env[key]).toBe("inside");
|
||||
throw new Error("boom");
|
||||
}),
|
||||
).toThrow("boom");
|
||||
|
||||
expect(process.env[key]).toBe(prev);
|
||||
});
|
||||
|
||||
it("withEnv can delete a key only inside callback", () => {
|
||||
const key = "OPENCLAW_ENV_TEST_SYNC_DELETE";
|
||||
const prev = process.env[key];
|
||||
|
||||
Reference in New Issue
Block a user