Files
OmniRoute/tests/unit/readyz-route.test.ts
backryun 79c5bdf681 fix(release): repair v3.8.50 base-red tail after latest root lift (#10964)
Merged after conflict triage: the six base-red repair files (vi.json, opencode.ts JSDoc, context-manager test, the three webhook dispatcher tests, the uncloseai orphan-test rename) were already drained on the tip by today's #11130/#11157/#11160/#11113 — those hunks resolved to the tip shape. What lands is the production-fix set: GLM transport-aware Anthropic headers, Claude Code-compatible model-listing rejection, combo live-test single-probe, zero-cost Auto-Combo interval normalization, recovery-clearing union handling, LLMLingua real-path compare, macOS netstat PID discovery, AI Horde R2 strict public-host validation. Sweep of every touched test file: 243/243 green; typecheck + file-size clean. (guide-settings-route's 4 reds reproduce on the pure tip — pre-existing drift from #11079, not from here.) Thank you @backryun!
2026-08-22 23:09:16 -03:00

60 lines
2.3 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import fs from "node:fs";
import {
markServerStarting,
markServerReady,
markServerStopping,
} from "../../src/lib/serverLifecycle.ts";
const readyz = await import("../../src/app/readyz/route.ts");
const healthz = await import("../../src/app/healthz/route.ts");
test("/readyz matches /healthz lifecycle for GET and HEAD", async () => {
assert.equal(readyz.dynamic, "force-dynamic");
markServerStarting();
const startingReady = await readyz.GET();
const startingHealth = await healthz.GET();
assert.equal(startingReady.status, 503);
assert.equal(startingHealth.status, 503);
assert.equal(await startingReady.text(), "starting\n");
assert.equal(await startingHealth.text(), "starting\n");
markServerReady();
const ready = await readyz.GET();
assert.equal(ready.status, 200);
assert.equal(ready.headers.get("Cache-Control"), "no-store");
assert.equal(ready.headers.get("Content-Type"), "text/plain; charset=utf-8");
assert.equal(await ready.text(), "ok\n");
const readyHead = await readyz.HEAD();
assert.equal(readyHead.status, 200);
assert.equal(await readyHead.text(), "");
markServerStopping();
const stopping = await readyz.GET();
assert.equal(stopping.status, 503);
assert.equal(await stopping.text(), "stopping\n");
const stoppingHealth = await healthz.GET();
assert.equal(stoppingHealth.status, 503);
});
test("/readyz is omitted from the centralized auth proxy matcher", () => {
const proxySource = fs.readFileSync("src/proxy.ts", "utf8");
const matcherBlock = proxySource.match(/matcher:\s*\[([\s\S]*?)\]/)?.[1];
assert.ok(matcherBlock, "proxy matcher configuration must remain discoverable");
assert.equal(/["']\/readyz/.test(matcherBlock), false);
assert.equal(/["']\/healthz/.test(matcherBlock), false);
});
test("/readyz re-exports the /healthz handlers and declares its route config locally", () => {
const source = fs.readFileSync("src/app/readyz/route.ts", "utf8");
assert.match(source, /from ["']\.\.\/healthz\/route["']/);
assert.match(source, /export const dynamic = ["']force-dynamic["']/);
assert.doesNotMatch(source, /export\s*\{[^}]*\bdynamic\b[^}]*\}\s*from/);
assert.equal(/monitoring/i.test(source), false);
assert.equal(/sqlite/i.test(source), false);
});