From bfd9fcac18453ca015a19f9797f4e66a7b72ca69 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Thu, 4 Jun 2026 23:39:00 +0100 Subject: [PATCH] test: remove redundant task flow temp dir args --- src/tasks/task-flow-registry.store.test.ts | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/tasks/task-flow-registry.store.test.ts b/src/tasks/task-flow-registry.store.test.ts index c1c4dda8a9ec..a7b8ab6fe938 100644 --- a/src/tasks/task-flow-registry.store.test.ts +++ b/src/tasks/task-flow-registry.store.test.ts @@ -6,7 +6,6 @@ import { executeSqliteQuerySync, getNodeSqliteKysely } from "../infra/kysely-syn import type { DB as OpenClawStateKyselyDatabase } from "../state/openclaw-state-db.generated.js"; import { openOpenClawStateDatabase } from "../state/openclaw-state-db.js"; import { resolveOpenClawStateSqlitePath } from "../state/openclaw-state-db.paths.js"; -import { withEnvAsync } from "../test-utils/env.js"; import { withOpenClawTestState } from "../test-utils/openclaw-test-state.js"; import { createManagedTaskFlow as createManagedTaskFlowOrNull, @@ -69,9 +68,10 @@ async function withFlowRegistryTempDir(run: (root: string) => Promise): Pr }, async (state) => { const root = state.stateDir; + process.env.OPENCLAW_STATE_DIR = root; resetTaskFlowRegistryForTests(); try { - return await withEnvAsync({ OPENCLAW_STATE_DIR: root }, async () => await run(root)); + return await run(root); } finally { resetTaskFlowRegistryForTests(); } @@ -79,6 +79,16 @@ async function withFlowRegistryTempDir(run: (root: string) => Promise): Pr ); } +const ORIGINAL_STATE_DIR = process.env.OPENCLAW_STATE_DIR; + +function restoreOriginalStateDir(): void { + if (ORIGINAL_STATE_DIR === undefined) { + delete process.env.OPENCLAW_STATE_DIR; + } else { + process.env.OPENCLAW_STATE_DIR = ORIGINAL_STATE_DIR; + } +} + describe("task-flow-registry store runtime", () => { beforeEach(() => { vi.useRealTimers(); @@ -86,6 +96,7 @@ describe("task-flow-registry store runtime", () => { afterEach(() => { vi.useRealTimers(); + restoreOriginalStateDir(); resetTaskFlowRegistryForTests(); }); @@ -150,7 +161,7 @@ describe("task-flow-registry store runtime", () => { }); it("rejects corrupt persisted flow rows during sqlite restore", async () => { - await withFlowRegistryTempDir(async (root) => { + await withFlowRegistryTempDir(async () => { resetTaskFlowRegistryForTests(); const created = createManagedTaskFlow({ @@ -174,7 +185,7 @@ describe("task-flow-registry store runtime", () => { }); it("drops invalid requester origins during sqlite restore", async () => { - await withFlowRegistryTempDir(async (root) => { + await withFlowRegistryTempDir(async () => { resetTaskFlowRegistryForTests(); const created = createManagedTaskFlow({ @@ -203,7 +214,7 @@ describe("task-flow-registry store runtime", () => { }); it("restores persisted wait-state, revision, and cancel intent from sqlite", async () => { - await withFlowRegistryTempDir(async (root) => { + await withFlowRegistryTempDir(async () => { resetTaskFlowRegistryForTests(); const created = createManagedTaskFlow({ @@ -248,7 +259,7 @@ describe("task-flow-registry store runtime", () => { }); it("round-trips explicit json null through sqlite", async () => { - await withFlowRegistryTempDir(async (root) => { + await withFlowRegistryTempDir(async () => { resetTaskFlowRegistryForTests(); const created = createManagedTaskFlow({ @@ -269,7 +280,7 @@ describe("task-flow-registry store runtime", () => { }); it("prunes large sqlite snapshots without binding every flow id at once", async () => { - await withFlowRegistryTempDir(async (root) => { + await withFlowRegistryTempDir(async () => { resetTaskFlowRegistryForTests(); const flows = new Map(); @@ -299,7 +310,7 @@ describe("task-flow-registry store runtime", () => { if (process.platform === "win32") { return; } - await withFlowRegistryTempDir(async (root) => { + await withFlowRegistryTempDir(async () => { resetTaskFlowRegistryForTests(); createManagedTaskFlow({