test: guard agent runtime config mock calls · openclaw/openclaw@bf2b408
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -63,6 +63,15 @@ async function withTempHome<T>(fn: (home: string) => Promise<T>): Promise<T> {
|
63 | 63 | return withTempHomeBase(fn, { prefix: "openclaw-agent-" }); |
64 | 64 | } |
65 | 65 | |
| 66 | +function requireResolveCommandConfigParams(callIndex = 0): ResolveCommandConfigParams { |
| 67 | +const call = resolveCommandConfigWithSecretsMock.mock.calls.at(callIndex); |
| 68 | +if (!call) { |
| 69 | +throw new Error(`expected command config resolution call ${callIndex}`); |
| 70 | +} |
| 71 | +const [params] = call; |
| 72 | +return params; |
| 73 | +} |
| 74 | + |
66 | 75 | function mockConfig(home: string, storePath: string): OpenClawConfig { |
67 | 76 | const cfg = { |
68 | 77 | agents: { |
@@ -153,7 +162,7 @@ describe("agentCommand runtime config", () => {
|
153 | 162 | targetIds: new Set(["models.providers.*.apiKey"]), |
154 | 163 | runtime, |
155 | 164 | }); |
156 | | -const targetIds = resolveCommandConfigWithSecretsMock.mock.calls[0]?.[0].targetIds; |
| 165 | +const targetIds = requireResolveCommandConfigParams().targetIds; |
157 | 166 | expect(targetIds.has("models.providers.*.apiKey")).toBe(true); |
158 | 167 | expect(targetIds.has("channels.telegram.botToken")).toBe(false); |
159 | 168 | expect(setRuntimeConfigSnapshotMock).toHaveBeenCalledWith(resolvedConfig, sourceConfig); |
@@ -180,7 +189,7 @@ describe("agentCommand runtime config", () => {
|
180 | 189 | runtimeTargetsChannelSecrets: true, |
181 | 190 | }); |
182 | 191 | |
183 | | -const targetIds = resolveCommandConfigWithSecretsMock.mock.calls[0]?.[0].targetIds; |
| 192 | +const targetIds = requireResolveCommandConfigParams().targetIds; |
184 | 193 | expect(targetIds.has("channels.telegram.botToken")).toBe(true); |
185 | 194 | }); |
186 | 195 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。