feat(health): service_status cache table + repo
This commit is contained in:
14
tests/repos/service_status.test.js
Normal file
14
tests/repos/service_status.test.js
Normal 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');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user