mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
test: remove redundant task flow temp dir args
This commit is contained in:
@@ -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<T>(run: (root: string) => Promise<T>): 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<T>(run: (root: string) => Promise<T>): 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<string, TaskFlowRecord>();
|
||||
@@ -299,7 +310,7 @@ describe("task-flow-registry store runtime", () => {
|
||||
if (process.platform === "win32") {
|
||||
return;
|
||||
}
|
||||
await withFlowRegistryTempDir(async (root) => {
|
||||
await withFlowRegistryTempDir(async () => {
|
||||
resetTaskFlowRegistryForTests();
|
||||
|
||||
createManagedTaskFlow({
|
||||
|
||||
Reference in New Issue
Block a user