Initial commit: Discord-Claude Gateway with event-driven agent runtime
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import { registerShutdownHandler } from "../../src/shutdown-handler.js";
|
||||
|
||||
vi.mock("../../src/logger.js", () => ({
|
||||
logger: {
|
||||
info: vi.fn(),
|
||||
debug: vi.fn(),
|
||||
warn: vi.fn(),
|
||||
error: vi.fn(),
|
||||
},
|
||||
}));
|
||||
|
||||
import { logger } from "../../src/logger.js";
|
||||
|
||||
describe("registerShutdownHandler", () => {
|
||||
let mockGateway: { shutdown: ReturnType<typeof vi.fn> };
|
||||
let sigintListeners: Array<() => void>;
|
||||
@@ -16,7 +27,7 @@ describe("registerShutdownHandler", () => {
|
||||
if (event === "SIGTERM") sigtermListeners.push(listener as () => void);
|
||||
return process;
|
||||
});
|
||||
vi.spyOn(console, "log").mockImplementation(() => {});
|
||||
vi.mocked(logger.info).mockClear();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -52,6 +63,9 @@ describe("registerShutdownHandler", () => {
|
||||
it("logs the signal name", () => {
|
||||
registerShutdownHandler(mockGateway as never);
|
||||
sigtermListeners[0]();
|
||||
expect(console.log).toHaveBeenCalledWith("Received SIGTERM, shutting down...");
|
||||
expect(logger.info).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ signal: "SIGTERM" }),
|
||||
expect.stringContaining("shutting down")
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user