refactor(test): use withEnvAsync in pairing store fixture

This commit is contained in:
Peter Steinberger
2026-02-21 13:06:12 +00:00
parent 21bb46d304
commit 25db01fe08

View File

@@ -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<T>(fn: (stateDir: string) => Promise<T>) {
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", () => {