mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-28 05:16:23 -06:00
feat(cli): support --json across reporting commands (#117928)
* feat(cli): support --json across reporting commands * test(cli): satisfy json command checks * test(cli): type json exception map
This commit is contained in:
committed by
GitHub
parent
4d14f298b0
commit
4c7a8d412b
@@ -482,6 +482,60 @@ describe("proxy cli runtime", () => {
|
||||
expect(process.exitCode).toBe(1);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: "coverage",
|
||||
run: async (runtime: typeof import("./proxy-cli.runtime.js")) =>
|
||||
await runtime.runDebugProxyCoverageCommand(),
|
||||
assertShape: (value: unknown) =>
|
||||
expect(value).toEqual({
|
||||
summary: expect.objectContaining({ total: expect.any(Number) }),
|
||||
entries: expect.any(Array),
|
||||
}),
|
||||
},
|
||||
{
|
||||
name: "sessions",
|
||||
run: async (runtime: typeof import("./proxy-cli.runtime.js")) =>
|
||||
await runtime.runDebugProxySessionsCommand({ json: true }),
|
||||
assertShape: (value: unknown) => expect(value).toEqual({ sessions: [] }),
|
||||
},
|
||||
{
|
||||
name: "query",
|
||||
run: async (runtime: typeof import("./proxy-cli.runtime.js")) =>
|
||||
await runtime.runDebugProxyQueryCommand({ json: true, preset: "double-sends" }),
|
||||
assertShape: (value: unknown) => expect(value).toEqual({ rows: [] }),
|
||||
},
|
||||
])("prints one undecorated JSON object for proxy $name --json", async ({ run, assertShape }) => {
|
||||
const runtime = await import("./proxy-cli.runtime.js");
|
||||
|
||||
await run(runtime);
|
||||
|
||||
expect(process.stdout["write"]).toHaveBeenCalledOnce();
|
||||
const output = String(vi.mocked(process.stdout["write"]).mock.calls[0]?.[0] ?? "");
|
||||
const parsed = JSON.parse(output) as unknown;
|
||||
assertShape(parsed);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{
|
||||
name: "sessions",
|
||||
run: async (runtime: typeof import("./proxy-cli.runtime.js")) =>
|
||||
await runtime.runDebugProxySessionsCommand({}),
|
||||
},
|
||||
{
|
||||
name: "query",
|
||||
run: async (runtime: typeof import("./proxy-cli.runtime.js")) =>
|
||||
await runtime.runDebugProxyQueryCommand({ preset: "double-sends" }),
|
||||
},
|
||||
])("preserves the legacy bare-array proxy $name output without --json", async ({ run }) => {
|
||||
const runtime = await import("./proxy-cli.runtime.js");
|
||||
|
||||
await run(runtime);
|
||||
|
||||
const output = String(vi.mocked(process.stdout["write"]).mock.calls[0]?.[0] ?? "");
|
||||
expect(JSON.parse(output)).toEqual([]);
|
||||
});
|
||||
|
||||
it.each([
|
||||
{ signal: "SIGINT" as const, exitCode: 130 },
|
||||
{ signal: "SIGTERM" as const, exitCode: 143 },
|
||||
|
||||
Reference in New Issue
Block a user