fix(selfhost): pin MinIO images and add application health checks
This commit is contained in:
@@ -3,6 +3,28 @@ import { test } from 'node:test';
|
||||
import Fastify from 'fastify';
|
||||
import healthRoutes from '../src/routes/health';
|
||||
|
||||
test('health checks the database and reports a failure without leaking connection details', async () => {
|
||||
const app = Fastify();
|
||||
let available = true;
|
||||
app.decorate('db', { execute: async () => {
|
||||
if (!available) throw new Error('postgres://secret@database');
|
||||
return { rows: [{ result: 1 }] };
|
||||
} } as any);
|
||||
try {
|
||||
await app.register(healthRoutes);
|
||||
const healthy = await app.inject('/health');
|
||||
assert.equal(healthy.statusCode, 200);
|
||||
assert.equal(healthy.json().status, 'ok');
|
||||
assert.equal(healthy.headers['cache-control'], 'no-store');
|
||||
available = false;
|
||||
const unhealthy = await app.inject('/health');
|
||||
assert.equal(unhealthy.statusCode, 503);
|
||||
assert.deepEqual(unhealthy.json(), { status: 'unavailable' });
|
||||
} finally {
|
||||
await app.close();
|
||||
}
|
||||
});
|
||||
|
||||
test('version endpoint reports image metadata without a database or authentication', async () => {
|
||||
const previousVersion = process.env.FEDEO_VERSION;
|
||||
const previousRevision = process.env.FEDEO_REVISION;
|
||||
|
||||
Reference in New Issue
Block a user