mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-08 15:02:53 +00:00
* test: split ACP translator bridge coverage * refactor: extract ACP translator session helpers * refactor: extract ACP manager backend failover helpers * test: split ACP manager failover coverage * test: split ACP manager runtime config coverage * test: split ACP manager turn result coverage * test: split ACP manager runtime handle coverage * test: keep ACP manager helpers within task boundaries * ci: split gateway runtime state test shard
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import { resetTaskFlowRegistryForTests } from "../../src/tasks/task-flow-registry.js";
|
|
import { configureTaskFlowRegistryRuntime } from "../../src/tasks/task-flow-registry.store.js";
|
|
import { findTaskByRunId, resetTaskRegistryForTests } from "../../src/tasks/task-registry.js";
|
|
import { withTempDir } from "../../src/test-helpers/temp-dir.js";
|
|
import { installInMemoryTaskRegistryRuntime } from "../../src/test-utils/task-registry-runtime.js";
|
|
|
|
export { findTaskByRunId };
|
|
|
|
export function resetAcpManagerTaskStateForTests(): void {
|
|
resetTaskRegistryForTests({ persist: false });
|
|
resetTaskFlowRegistryForTests({ persist: false });
|
|
}
|
|
|
|
export async function withAcpManagerTaskStateDir(
|
|
run: (root: string) => Promise<void>,
|
|
): Promise<void> {
|
|
await withTempDir({ prefix: "openclaw-acp-manager-task-" }, async (root) => {
|
|
process.env.OPENCLAW_STATE_DIR = root;
|
|
resetAcpManagerTaskStateForTests();
|
|
installInMemoryTaskRegistryRuntime();
|
|
configureTaskFlowRegistryRuntime({
|
|
store: {
|
|
loadSnapshot: () => ({
|
|
flows: new Map(),
|
|
}),
|
|
saveSnapshot: () => {},
|
|
upsertFlow: () => {},
|
|
deleteFlow: () => {},
|
|
close: () => {},
|
|
},
|
|
});
|
|
try {
|
|
await run(root);
|
|
} finally {
|
|
resetAcpManagerTaskStateForTests();
|
|
}
|
|
});
|
|
}
|
|
|
|
export function requireTaskByRunId(runId: string) {
|
|
const task = findTaskByRunId(runId);
|
|
if (!task) {
|
|
throw new Error(`Expected task for run ${runId}`);
|
|
}
|
|
return task;
|
|
}
|