15 lines
675 B
JavaScript
15 lines
675 B
JavaScript
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');
|
|
});
|
|
});
|