mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-16 18:34:18 +00:00
test: dedupe mcp cli mock reads
This commit is contained in:
@@ -51,7 +51,16 @@ async function runMcpCommand(args: string[]) {
|
||||
}
|
||||
|
||||
function lastLogLine(): string {
|
||||
return String(mockLog.mock.calls.at(-1)?.[0] ?? "");
|
||||
return lastRuntimeLine(mockLog);
|
||||
}
|
||||
|
||||
function lastErrorLine(): string {
|
||||
return lastRuntimeLine(mockError);
|
||||
}
|
||||
|
||||
function lastRuntimeLine(mock: typeof mockLog): string {
|
||||
const call = mock.mock.calls[mock.mock.calls.length - 1];
|
||||
return String(call?.[0] ?? "");
|
||||
}
|
||||
|
||||
describe("mcp cli", () => {
|
||||
@@ -94,8 +103,7 @@ describe("mcp cli", () => {
|
||||
vi.spyOn(process, "cwd").mockReturnValue(workspaceDir);
|
||||
|
||||
await expect(runMcpCommand(["mcp", "unset", "missing"])).rejects.toThrow("__exit__:1");
|
||||
const errorLine = String(mockError.mock.calls.at(-1)?.[0] ?? "");
|
||||
expect(errorLine).toBe(
|
||||
expect(lastErrorLine()).toBe(
|
||||
`No MCP server named "missing" in ${configPath}. Run openclaw mcp list to see configured servers.`,
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user