

























@@ -13,7 +13,11 @@ describe("doctor startup channel maintenance", () => {
1313},
1414};
1515const calls: unknown[] = [];
16-const runtime = { log() {}, error() {} };
16+const runtimeCalls: string[] = [];
17+const runtime = {
18+log: (message: string) => runtimeCalls.push(`log:${message}`),
19+error: (message: string) => runtimeCalls.push(`error:${message}`),
20+};
17211822await maybeRunDoctorStartupChannelMaintenance({
1923 cfg,
@@ -26,18 +30,25 @@ describe("doctor startup channel maintenance", () => {
2630});
27312832expect(calls).toHaveLength(1);
29-expect(calls[0]).toEqual(
30-expect.objectContaining({
31- cfg,
32-env: { OPENCLAW_TEST: "1" },
33-trigger: "doctor-fix",
34-logPrefix: "doctor",
35-log: expect.objectContaining({
36-info: expect.any(Function),
37-warn: expect.any(Function),
38-}),
39-}),
40-);
33+const [call] = calls as Array<{
34+cfg: typeof cfg;
35+env: { OPENCLAW_TEST: string };
36+log: { info: (message: string) => void; warn: (message: string) => void };
37+trigger: string;
38+logPrefix: string;
39+}>;
40+if (!call) {
41+throw new Error("Expected startup maintenance call");
42+}
43+expect(call.cfg).toBe(cfg);
44+expect(call.env).toEqual({ OPENCLAW_TEST: "1" });
45+expect(call.trigger).toBe("doctor-fix");
46+expect(call.logPrefix).toBe("doctor");
47+expect(call.log.info).toBeTypeOf("function");
48+expect(call.log.warn).toBeTypeOf("function");
49+call.log.info("migrated");
50+call.log.warn("needs attention");
51+expect(runtimeCalls).toEqual(["log:migrated", "error:needs attention"]);
4152});
42534354it("skips startup migration outside repair flows", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。