test(perf): stub expensive cli coverage integration paths
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { Command } from "commander";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { withEnvOverride } from "../config/test-helpers.js";
|
||||
import { GatewayLockError } from "../infra/gateway-lock.js";
|
||||
import { createCliRuntimeCapture } from "./test-runtime-capture.js";
|
||||
|
||||
type DiscoveredBeacon = Awaited<
|
||||
@@ -26,6 +27,8 @@ const discoverGatewayBeacons = vi.fn<(opts: unknown) => Promise<DiscoveredBeacon
|
||||
async () => [],
|
||||
);
|
||||
const gatewayStatusCommand = vi.fn<(opts: unknown) => Promise<void>>(async () => {});
|
||||
const inspectPortUsage = vi.fn(async (_port: number) => ({ status: "free" as const }));
|
||||
const formatPortDiagnostics = vi.fn(() => [] as string[]);
|
||||
|
||||
const { runtimeLogs, runtimeErrors, defaultRuntime, resetRuntimeCapture } =
|
||||
createCliRuntimeCapture();
|
||||
@@ -85,6 +88,11 @@ vi.mock("../commands/gateway-status.js", () => ({
|
||||
gatewayStatusCommand: (opts: unknown) => gatewayStatusCommand(opts),
|
||||
}));
|
||||
|
||||
vi.mock("../infra/ports.js", () => ({
|
||||
inspectPortUsage: (port: number) => inspectPortUsage(port),
|
||||
formatPortDiagnostics: (diagnostics: unknown) => formatPortDiagnostics(diagnostics),
|
||||
}));
|
||||
|
||||
const { registerGatewayCli } = await import("./gateway-cli.js");
|
||||
let gatewayProgram: Command;
|
||||
|
||||
@@ -106,6 +114,8 @@ async function expectGatewayExit(args: string[]) {
|
||||
describe("gateway-cli coverage", () => {
|
||||
beforeEach(() => {
|
||||
gatewayProgram = createGatewayProgram();
|
||||
inspectPortUsage.mockClear();
|
||||
formatPortDiagnostics.mockClear();
|
||||
});
|
||||
|
||||
it("registers call/health commands and routes to callGateway", async () => {
|
||||
@@ -216,8 +226,6 @@ describe("gateway-cli coverage", () => {
|
||||
it("prints stop hints on GatewayLockError when service is loaded", async () => {
|
||||
resetRuntimeCapture();
|
||||
serviceIsLoaded.mockResolvedValue(true);
|
||||
|
||||
const { GatewayLockError } = await import("../infra/gateway-lock.js");
|
||||
startGatewayServer.mockRejectedValueOnce(
|
||||
new GatewayLockError("another gateway instance is already listening"),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user