


























@@ -36,6 +36,19 @@ vi.mock("../agents/pi-embedded-runner/runtime.js", () => ({
3636let prewarmConfiguredPrimaryModel: typeof import("./server-startup-post-attach.js").__testing.prewarmConfiguredPrimaryModel;
3737let shouldSkipStartupModelPrewarm: typeof import("./server-startup-post-attach.js").__testing.shouldSkipStartupModelPrewarm;
383839+function expectModelsJsonPrewarmCall(cfg: OpenClawConfig) {
40+expect(ensureOpenClawModelsJsonMock).toHaveBeenCalledTimes(1);
41+const [calledConfig, agentDir, options] = ensureOpenClawModelsJsonMock.mock.calls[0] ?? [];
42+expect(calledConfig).toBe(cfg);
43+expect(agentDir).toBe("/tmp/agent");
44+expect(options).toEqual({
45+workspaceDir: "/tmp/workspace",
46+providerDiscoveryProviderIds: ["openai-codex"],
47+providerDiscoveryTimeoutMs: 5000,
48+providerDiscoveryEntriesOnly: true,
49+});
50+}
51+3952describe("gateway startup primary model warmup", () => {
4053beforeAll(async () => {
4154({
@@ -66,16 +79,7 @@ describe("gateway startup primary model warmup", () => {
6679log: { warn: vi.fn() },
6780});
688169-expect(ensureOpenClawModelsJsonMock).toHaveBeenCalledWith(
70-cfg,
71-"/tmp/agent",
72-expect.objectContaining({
73-workspaceDir: "/tmp/workspace",
74-providerDiscoveryProviderIds: ["openai-codex"],
75-providerDiscoveryTimeoutMs: 5000,
76-providerDiscoveryEntriesOnly: true,
77-}),
78-);
82+expectModelsJsonPrewarmCall(cfg);
7983expect(piModelModuleLoadedMock).not.toHaveBeenCalled();
8084});
8185@@ -163,16 +167,7 @@ describe("gateway startup primary model warmup", () => {
163167log: { warn: vi.fn() },
164168});
165169166-expect(ensureOpenClawModelsJsonMock).toHaveBeenCalledWith(
167-cfg,
168-"/tmp/agent",
169-expect.objectContaining({
170-workspaceDir: "/tmp/workspace",
171-providerDiscoveryProviderIds: ["openai-codex"],
172-providerDiscoveryTimeoutMs: 5000,
173-providerDiscoveryEntriesOnly: true,
174-}),
175-);
170+expectModelsJsonPrewarmCall(cfg);
176171expect(piModelModuleLoadedMock).not.toHaveBeenCalled();
177172});
178173此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。