From bf2b40866d541bcf3e1ee08255f6a77702fadae9 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Tue, 12 May 2026 04:25:30 +0100 Subject: [PATCH] test: guard agent runtime config mock calls --- src/commands/agent.runtime-config.test.ts | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/commands/agent.runtime-config.test.ts b/src/commands/agent.runtime-config.test.ts index 6869337517e..03db12f2baf 100644 --- a/src/commands/agent.runtime-config.test.ts +++ b/src/commands/agent.runtime-config.test.ts @@ -63,6 +63,15 @@ async function withTempHome(fn: (home: string) => Promise): Promise { return withTempHomeBase(fn, { prefix: "openclaw-agent-" }); } +function requireResolveCommandConfigParams(callIndex = 0): ResolveCommandConfigParams { + const call = resolveCommandConfigWithSecretsMock.mock.calls.at(callIndex); + if (!call) { + throw new Error(`expected command config resolution call ${callIndex}`); + } + const [params] = call; + return params; +} + function mockConfig(home: string, storePath: string): OpenClawConfig { const cfg = { agents: { @@ -153,7 +162,7 @@ describe("agentCommand runtime config", () => { targetIds: new Set(["models.providers.*.apiKey"]), runtime, }); - const targetIds = resolveCommandConfigWithSecretsMock.mock.calls[0]?.[0].targetIds; + const targetIds = requireResolveCommandConfigParams().targetIds; expect(targetIds.has("models.providers.*.apiKey")).toBe(true); expect(targetIds.has("channels.telegram.botToken")).toBe(false); expect(setRuntimeConfigSnapshotMock).toHaveBeenCalledWith(resolvedConfig, sourceConfig); @@ -180,7 +189,7 @@ describe("agentCommand runtime config", () => { runtimeTargetsChannelSecrets: true, }); - const targetIds = resolveCommandConfigWithSecretsMock.mock.calls[0]?.[0].targetIds; + const targetIds = requireResolveCommandConfigParams().targetIds; expect(targetIds.has("channels.telegram.botToken")).toBe(true); }); });