Deploy FileDrop / deploy (push) Failing after 12s
- Deleted `upload.ts` and `web-api.ts` routes, consolidating logic into dedicated controllers. - Updated import paths in tests to reflect new controller structure. - Refactored Telegram API utilities to utilize a bot pool for improved bot management and error handling. - Enhanced environment variable tests to ensure additional bot tokens are correctly populated. - Adjusted S3 bucket configuration tests to align with new controller imports. - Updated Telegram queue implementation to reflect new infrastructure organization.
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { beforeEach, describe, expect, it, mock } from 'bun:test';
|
|
|
|
// Mock database layer
|
|
const mockExecute = mock(() => Promise.resolve());
|
|
|
|
mock.module('../src/infrastructure/persistence/drizzle/index', () => ({
|
|
db: {
|
|
execute: mockExecute,
|
|
},
|
|
}));
|
|
|
|
describe('Health Route Handler', () => {
|
|
let handleHealth: typeof import('../src/interfaces/http/controllers/health-controller').handleHealth;
|
|
|
|
beforeEach(async () => {
|
|
mockExecute.mockClear();
|
|
const healthRoute = await import('../src/interfaces/http/controllers/health-controller');
|
|
handleHealth = healthRoute.handleHealth;
|
|
});
|
|
|
|
it('should return status 200 and ok when DB is healthy', async () => {
|
|
const req = new Request('http://localhost:3000/health');
|
|
const res = await handleHealth(req);
|
|
|
|
expect(res.status).toBe(200);
|
|
const body = await res.json();
|
|
expect(body).toEqual({ status: 'ok' });
|
|
expect(mockExecute).toHaveBeenCalled();
|
|
});
|
|
|
|
it('should return status 500 and error details when DB health check fails', async () => {
|
|
mockExecute.mockImplementationOnce(() => Promise.reject(new Error('DB Connection Failed')));
|
|
const req = new Request('http://localhost:3000/health');
|
|
const res = await handleHealth(req);
|
|
|
|
expect(res.status).toBe(500);
|
|
const body = await res.json();
|
|
expect(body.status).toBe('error');
|
|
expect(body.error).toBe('DB Connection Failed');
|
|
});
|
|
});
|