-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathhealthz.test.js
More file actions
23 lines (19 loc) · 1.06 KB
/
Copy pathhealthz.test.js
File metadata and controls
23 lines (19 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import test from "node:test";
import assert from "node:assert/strict";
// Minimal regression guard: ensure the server source contains the public /healthz endpoint.
// (This repo doesn't have an easy way to import the express app without starting a server.)
import fs from "node:fs";
test("server exposes /healthz endpoint", () => {
const src = fs.readFileSync(new URL("../src/server.js", import.meta.url), "utf8");
assert.match(src, /app\.get\("\/healthz"/);
});
test("healthz returns 503 when configured gateway is unreachable", () => {
const src = fs.readFileSync(new URL("../src/server.js", import.meta.url), "utf8");
assert.match(src, /const healthy = !configured \|\| gatewayReachable/);
assert.match(src, /res\.status\(healthy \? 200 : 503\)\.json\(/);
});
test("healthz can schedule gateway restart when unreachable", () => {
const src = fs.readFileSync(new URL("../src/server.js", import.meta.url), "utf8");
assert.match(src, /scheduleGatewayRestart\("healthcheck-unreachable"\)/);
assert.match(src, /restartScheduled: Boolean\(gatewayRestartTimer\)/);
});