diff --git a/src/pairing/pairing-store.test.ts b/src/pairing/pairing-store.test.ts index d233f1120..1d060fbd8 100644 --- a/src/pairing/pairing-store.test.ts +++ b/src/pairing/pairing-store.test.ts @@ -4,7 +4,7 @@ import os from "node:os"; import path from "node:path"; import { afterAll, beforeAll, describe, expect, it, vi } from "vitest"; import { resolveOAuthDir } from "../config/paths.js"; -import { captureEnv } from "../test-utils/env.js"; +import { withEnvAsync } from "../test-utils/env.js"; import { addChannelAllowFromStoreEntry, approveChannelPairingCode, @@ -27,15 +27,9 @@ afterAll(async () => { }); async function withTempStateDir(fn: (stateDir: string) => Promise) { - const envSnapshot = captureEnv(["OPENCLAW_STATE_DIR"]); const dir = path.join(fixtureRoot, `case-${caseId++}`); await fs.mkdir(dir, { recursive: true }); - process.env.OPENCLAW_STATE_DIR = dir; - try { - return await fn(dir); - } finally { - envSnapshot.restore(); - } + return await withEnvAsync({ OPENCLAW_STATE_DIR: dir }, async () => await fn(dir)); } describe("pairing store", () => {