mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 10:57:40 +00:00
refactor(agent): dedupe harness and command workflows
This commit is contained in:
35
src/agents/openclaw-tools.subagents.test-harness.ts
Normal file
35
src/agents/openclaw-tools.subagents.test-harness.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { vi } from "vitest";
|
||||
|
||||
export type LoadedConfig = ReturnType<(typeof import("../config/config.js"))["loadConfig"]>;
|
||||
|
||||
export const callGatewayMock = vi.fn();
|
||||
|
||||
const defaultConfig: LoadedConfig = {
|
||||
session: {
|
||||
mainKey: "main",
|
||||
scope: "per-sender",
|
||||
},
|
||||
};
|
||||
|
||||
let configOverride: LoadedConfig = defaultConfig;
|
||||
|
||||
export function setSubagentsConfigOverride(next: LoadedConfig) {
|
||||
configOverride = next;
|
||||
}
|
||||
|
||||
export function resetSubagentsConfigOverride() {
|
||||
configOverride = defaultConfig;
|
||||
}
|
||||
|
||||
vi.mock("../gateway/call.js", () => ({
|
||||
callGateway: (opts: unknown) => callGatewayMock(opts),
|
||||
}));
|
||||
|
||||
vi.mock("../config/config.js", async (importOriginal) => {
|
||||
const actual = await importOriginal<typeof import("../config/config.js")>();
|
||||
return {
|
||||
...actual,
|
||||
loadConfig: () => configOverride,
|
||||
resolveGatewayPort: () => 18789,
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user