CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
Blame · Line-by-line history
version-endpoint.test.ts
Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.
| 05cdb85 | 1 | /** |
| 2 | * /api/version smoke + build-info shape tests. | |
| 3 | */ | |
| 4 | import { describe, expect, it } from "bun:test"; | |
| 5 | import { Hono } from "hono"; | |
| 6 | import versionRoutes from "../routes/version"; | |
| 7 | import { getBuildInfo } from "../lib/build-info"; | |
| 8 | ||
| 9 | describe("/api/version", () => { | |
| 10 | const app = new Hono(); | |
| 11 | app.route("/", versionRoutes); | |
| 12 | ||
| 13 | it("returns 200 + JSON with sha + uptimeMs + builtAt", async () => { | |
| 14 | const res = await app.request("/api/version"); | |
| 15 | expect(res.status).toBe(200); | |
| 16 | expect(res.headers.get("cache-control") || "").toContain("no-store"); | |
| 17 | const body = (await res.json()) as Record<string, unknown>; | |
| 18 | expect(typeof body.sha).toBe("string"); | |
| 19 | expect(typeof body.shaFull).toBe("string"); | |
| 20 | expect(typeof body.branch).toBe("string"); | |
| 21 | expect(typeof body.builtAt).toBe("string"); | |
| 22 | expect(typeof body.uptimeMs).toBe("number"); | |
| 23 | expect((body.sha as string).length).toBeGreaterThan(0); | |
| 24 | }); | |
| 25 | ||
| 26 | it("returns short sha (7 chars or 'unknown')", () => { | |
| 27 | const b = getBuildInfo(); | |
| 28 | expect(b.sha === "unknown" || b.sha.length === 7).toBe(true); | |
| 29 | }); | |
| 30 | ||
| 31 | it("uptimeMs increments between calls", async () => { | |
| 32 | const a = getBuildInfo().uptimeMs; | |
| 33 | await new Promise((r) => setTimeout(r, 5)); | |
| 34 | const b = getBuildInfo().uptimeMs; | |
| 35 | expect(b).toBeGreaterThan(a); | |
| 36 | }); | |
| 37 | }); |