Initial commit: Discord-Claude Gateway with event-driven agent runtime

This commit is contained in:
2026-02-22 13:59:57 -05:00
parent b4f340b610
commit f2247ea3ac
28 changed files with 2056 additions and 205 deletions

View File

@@ -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")
);
});
});