mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-21 21:56:46 +00:00
test: guard agent runtime config mock calls
This commit is contained in:
@@ -63,6 +63,15 @@ async function withTempHome<T>(fn: (home: string) => Promise<T>): Promise<T> {
|
||||
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);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user