test: snapshot task flow maintenance env

This commit is contained in:
Shakker
2026-06-05 00:59:05 +01:00
parent 99a838fac4
commit 9f6ed16a6d

View File

@@ -1,5 +1,6 @@
// Covers maintenance reconciliation for managed task-flow records.
import { afterEach, describe, expect, it } from "vitest";
import { captureEnv } from "../test-utils/env.js";
import { withOpenClawTestState } from "../test-utils/openclaw-test-state.js";
import { createRunningTaskRun as createRunningTaskRunOrNull } from "./task-executor.js";
import {
@@ -22,7 +23,7 @@ import {
} from "./task-registry.js";
import type { TaskRecord } from "./task-registry.types.js";
const ORIGINAL_STATE_DIR = process.env.OPENCLAW_STATE_DIR;
const ORIGINAL_ENV = captureEnv(["OPENCLAW_STATE_DIR"]);
function createFlowRecord(params: Parameters<typeof createFlowRecordOrNull>[0]): TaskFlowRecord {
const flow = createFlowRecordOrNull(params);
@@ -77,11 +78,7 @@ async function withTaskFlowMaintenanceStateDir(
describe("task-flow-registry maintenance", () => {
afterEach(() => {
if (ORIGINAL_STATE_DIR === undefined) {
delete process.env.OPENCLAW_STATE_DIR;
} else {
process.env.OPENCLAW_STATE_DIR = ORIGINAL_STATE_DIR;
}
ORIGINAL_ENV.restore();
resetTaskRegistryDeliveryRuntimeForTests();
resetTaskRegistryForTests();
resetTaskFlowRegistryForTests();