Add observability and integration coverage (#2)
ci / test (push) Successful in 9s

Co-authored-by: luna <clawy@reversed.dev>
Co-committed-by: luna <clawy@reversed.dev>
This commit was merged in pull request #2.
This commit is contained in:
2026-07-21 20:05:25 +02:00
committed by Luna
parent 91c0ed7332
commit 7e4a46a5d3
8 changed files with 353 additions and 8 deletions
+19
View File
@@ -106,6 +106,25 @@ test("GET /loc accepts api_key query param as an unsafe fallback", async () => {
assert.equal(response.body.lineCount, 5);
});
test("GET /metrics is authenticated and exposes Prometheus counters", async () => {
const app = createApp({ ...baseConfig, apiKey: "secret" }, {
getHealth: () => ({ cacheEntries: 0, inFlight: 0, maxConcurrentScans: 4, activeScans: 0, queuedScans: 0 }),
getPublicKey: async () => "ssh-ed25519 AAAA",
getDefaultKeyName: () => "loc_via_git_ed25519",
count: async () => {
throw new Error("not used");
}
});
const unauthenticated = await request(app).get("/metrics");
const authenticated = await request(app).get("/metrics").set("x-api-key", "secret");
assert.equal(unauthenticated.status, 401);
assert.equal(authenticated.status, 200);
assert.match(authenticated.text, /loc_via_git_http_requests_total/);
assert.match(authenticated.text, /loc_via_git_scans_total 0/);
});
test("GET /loc/diff returns aggregate and language deltas", async () => {
const app = createApp(baseConfig, {
getHealth: () => ({ cacheEntries: 0, inFlight: 0, maxConcurrentScans: 4, activeScans: 0, queuedScans: 0 }),