process-readiness.test.ts

1.0 KB · raw

1import { mkdtempSync, writeFileSync } from "node:fs";2import { tmpdir } from "node:os";3import { resolve } from "node:path";4import { describe, expect, it } from "vitest";5import { waitForFile } from "./process-readiness.mjs";67describe("process endpoint readiness", () => {8  it("allows a cold endpoint to start after the legacy 30-second boundary", async () => {9    const path = resolve(mkdtempSync(resolve(tmpdir(), "peach-ready-test-")), "port");10    const child = { exitCode: null, diagnostics: { stdout: "gradle startup", stderr: "" } };11    setTimeout(() => writeFileSync(path, "49142"), 35);1213    await expect(waitForFile(path, child, 90, 1)).resolves.toBe("49142");14  });1516  it("includes endpoint output when readiness times out", async () => {17    const path = resolve(mkdtempSync(resolve(tmpdir(), "peach-ready-test-")), "port");18    const child = { exitCode: null, diagnostics: { stdout: "gradle startup", stderr: "daemon busy" } };1920    await expect(waitForFile(path, child, 5, 1)).rejects.toThrow(/gradle startup.*daemon busy/);21  });22});