test: share restart health stopped-free fixture

This commit is contained in:
Peter Steinberger
2026-04-19 00:48:17 +01:00
parent ac0515ce7e
commit 7b7d69a31e

View File

@@ -88,6 +88,24 @@ async function inspectAmbiguousOwnershipWithProbe(
});
}
async function waitForStoppedFreeGatewayRestart() {
const service = makeGatewayService({ status: "stopped" });
inspectPortUsage.mockResolvedValue({
port: 18789,
status: "free",
listeners: [],
hints: [],
});
const { waitForGatewayHealthyRestart } = await import("./restart-health.js");
return waitForGatewayHealthyRestart({
service,
port: 18789,
attempts: 120,
delayMs: 500,
});
}
describe("inspectGatewayRestart", () => {
beforeEach(() => {
inspectPortUsage.mockReset();
@@ -252,21 +270,7 @@ describe("inspectGatewayRestart", () => {
});
it("annotates stopped-free early exits with the actual elapsed time", async () => {
const service = makeGatewayService({ status: "stopped" });
inspectPortUsage.mockResolvedValue({
port: 18789,
status: "free",
listeners: [],
hints: [],
});
const { waitForGatewayHealthyRestart } = await import("./restart-health.js");
const snapshot = await waitForGatewayHealthyRestart({
service,
port: 18789,
attempts: 120,
delayMs: 500,
});
const snapshot = await waitForStoppedFreeGatewayRestart();
expect(snapshot).toMatchObject({
healthy: false,
@@ -280,21 +284,8 @@ describe("inspectGatewayRestart", () => {
it("waits longer before stopped-free early exit on Windows", async () => {
Object.defineProperty(process, "platform", { value: "win32", configurable: true });
const service = makeGatewayService({ status: "stopped" });
inspectPortUsage.mockResolvedValue({
port: 18789,
status: "free",
listeners: [],
hints: [],
});
const { waitForGatewayHealthyRestart } = await import("./restart-health.js");
const snapshot = await waitForGatewayHealthyRestart({
service,
port: 18789,
attempts: 120,
delayMs: 500,
});
const snapshot = await waitForStoppedFreeGatewayRestart();
expect(snapshot).toMatchObject({
healthy: false,