feat(health): service_status cache table + repo

This commit is contained in:
root
2026-06-02 22:53:39 +10:00
parent 3ea34d9907
commit 5b05fd4730
3 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import { describe, it, expect, beforeAll } from 'vitest';
import { resetDb } from '../helpers/db.js';
import { migrateUp } from '../../lib/db/migrate.js';
import * as repo from '../../lib/db/repos/service_status.js';
beforeAll(async () => { await resetDb(); await migrateUp(); });
describe('service_status repo', () => {
it('upserts and reads all', async () => {
await repo.upsert({ service_id: 'gitea', status: 'ok', latency_ms: 12, detail: '200' });
await repo.upsert({ service_id: 'gitea', status: 'down', latency_ms: null, detail: 'ECONN' });
const all = await repo.all();
expect(all.find(r => r.service_id === 'gitea').status).toBe('down');
});
});