mirror of https://github.com/openclaw/openclaw.git
test(cli): cover send and gateway_stop failure path
This commit is contained in:
parent
bc1edeba33
commit
b45d4dc388
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue