mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-30 09:11:20 +00:00
test(subagents): mock sessions store in steer-restart coverage
This commit is contained in:
committed by
Peter Steinberger
parent
d0e008d460
commit
3c13f4c2b4
@@ -38,6 +38,31 @@ vi.mock("../config/config.js", () => ({
|
||||
})),
|
||||
}));
|
||||
|
||||
vi.mock("../config/sessions.js", () => {
|
||||
const sessionStore = new Proxy<Record<string, { sessionId: string; updatedAt: number }>>(
|
||||
{},
|
||||
{
|
||||
get(target, prop, receiver) {
|
||||
if (typeof prop !== "string" || prop in target) {
|
||||
return Reflect.get(target, prop, receiver);
|
||||
}
|
||||
return { sessionId: `sess-${prop}`, updatedAt: 1 };
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
return {
|
||||
loadSessionStore: vi.fn(() => sessionStore),
|
||||
resolveAgentIdFromSessionKey: (key: string) => {
|
||||
const match = key.match(/^agent:([^:]+)/);
|
||||
return match?.[1] ?? "main";
|
||||
},
|
||||
resolveMainSessionKey: () => "agent:main:main",
|
||||
resolveStorePath: () => "/tmp/test-store",
|
||||
updateSessionStore: vi.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
const announceSpy = vi.fn(async (_params: unknown) => true);
|
||||
const runSubagentEndedHookMock = vi.fn(async (_event?: unknown, _ctx?: unknown) => {});
|
||||
vi.mock("./subagent-announce.js", () => ({
|
||||
|
||||
Reference in New Issue
Block a user