refactor(test): simplify oauth/profile env restore

This commit is contained in:
Peter Steinberger
2026-02-16 00:03:45 +00:00
parent c07036e813
commit e075a33ca3
2 changed files with 8 additions and 14 deletions

View File

@@ -1,18 +1,15 @@
import { afterAll, beforeAll, describe, expect, it, vi } from "vitest";
import { captureEnv } from "../test-utils/env.js";
let previousProfile: string | undefined;
let envSnapshot: ReturnType<typeof captureEnv>;
beforeAll(() => {
previousProfile = process.env.OPENCLAW_PROFILE;
envSnapshot = captureEnv(["OPENCLAW_PROFILE"]);
process.env.OPENCLAW_PROFILE = "isolated";
});
afterAll(() => {
if (previousProfile === undefined) {
delete process.env.OPENCLAW_PROFILE;
} else {
process.env.OPENCLAW_PROFILE = previousProfile;
}
envSnapshot.restore();
});
const mocks = vi.hoisted(() => ({