mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-23 18:15:44 +02:00
test(cli): cover send and gateway_stop failure path
This commit is contained in:
@@ -121,6 +121,22 @@ describe("runMessageAction", () => {
|
||||
expect(exitMock).toHaveBeenCalledWith(0);
|
||||
});
|
||||
|
||||
it("logs gateway_stop failure and preserves failure exit code when send fails", async () => {
|
||||
hasHooksMock.mockReturnValueOnce(true);
|
||||
messageCommandMock.mockRejectedValueOnce(new Error("send failed"));
|
||||
runGatewayStopMock.mockRejectedValueOnce(new Error("hook failed"));
|
||||
const fakeCommand = { help: vi.fn() } as never;
|
||||
const { runMessageAction } = createMessageCliHelpers(fakeCommand, "discord");
|
||||
|
||||
await expect(
|
||||
runMessageAction("send", { channel: "discord", target: "123", message: "hi" }),
|
||||
).rejects.toThrow("exit");
|
||||
|
||||
expect(errorMock).toHaveBeenNthCalledWith(1, "Error: send failed");
|
||||
expect(errorMock).toHaveBeenNthCalledWith(2, "gateway_stop hook failed: Error: hook failed");
|
||||
expect(exitMock).toHaveBeenCalledWith(1);
|
||||
});
|
||||
|
||||
it("does not call exit(0) when the action throws", async () => {
|
||||
messageCommandMock.mockRejectedValueOnce(new Error("boom"));
|
||||
const fakeCommand = { help: vi.fn() } as never;
|
||||
|
||||
Reference in New Issue
Block a user