




















@@ -41,6 +41,21 @@ function makeEvent(overrides?: Partial<InternalHookEvent>): InternalHookEvent {
4141};
4242}
434344+function expectBootCall(
45+index: number,
46+expected: { cfg: unknown; workspaceDir: string; agentId: string },
47+) {
48+const params = runBootOnce.mock.calls[index]?.[0] as
49+| { cfg?: unknown; workspaceDir?: unknown; agentId?: unknown }
50+| undefined;
51+if (!params) {
52+throw new Error(`missing boot call ${index}`);
53+}
54+expect(params.cfg).toBe(expected.cfg);
55+expect(params.workspaceDir).toBe(expected.workspaceDir);
56+expect(params.agentId).toBe(expected.agentId);
57+}
58+4459describe("boot-md handler", () => {
4560function setupTwoAgentBootConfig() {
4661const cfg = { agents: { list: [{ id: "main" }, { id: "ops" }] } };
@@ -84,12 +99,8 @@ describe("boot-md handler", () => {
849985100expect(listAgentIds).toHaveBeenCalledWith(cfg);
86101expect(runBootOnce).toHaveBeenCalledTimes(2);
87-expect(runBootOnce).toHaveBeenCalledWith(
88-expect.objectContaining({ cfg, workspaceDir: MAIN_WORKSPACE_DIR, agentId: "main" }),
89-);
90-expect(runBootOnce).toHaveBeenCalledWith(
91-expect.objectContaining({ cfg, workspaceDir: OPS_WORKSPACE_DIR, agentId: "ops" }),
92-);
102+expectBootCall(0, { cfg, workspaceDir: MAIN_WORKSPACE_DIR, agentId: "main" });
103+expectBootCall(1, { cfg, workspaceDir: OPS_WORKSPACE_DIR, agentId: "ops" });
93104});
9410595106it("runs boot for single default agent when no agents configured", async () => {
@@ -99,9 +110,7 @@ describe("boot-md handler", () => {
99110await runBootChecklist(makeEvent({ context: { cfg } }));
100111101112expect(runBootOnce).toHaveBeenCalledTimes(1);
102-expect(runBootOnce).toHaveBeenCalledWith(
103-expect.objectContaining({ cfg, workspaceDir: MAIN_WORKSPACE_DIR, agentId: "main" }),
104-);
113+expectBootCall(0, { cfg, workspaceDir: MAIN_WORKSPACE_DIR, agentId: "main" });
105114});
106115107116it("logs warning details when a per-agent boot run fails", async () => {
@@ -144,8 +153,6 @@ describe("boot-md handler", () => {
144153await runBootChecklist(makeEvent({ context: { cfg } }));
145154146155expect(runBootOnce).toHaveBeenCalledTimes(1);
147-expect(runBootOnce).toHaveBeenCalledWith(
148-expect.objectContaining({ cfg, workspaceDir: MAIN_WORKSPACE_DIR, agentId: "main" }),
149-);
156+expectBootCall(0, { cfg, workspaceDir: MAIN_WORKSPACE_DIR, agentId: "main" });
150157});
151158});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。