refactor(test): use withEnvAsync in pairing store fixture
This commit is contained in:
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user