refactor(core): Migrate DB setup to use DI (#15324)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2025-05-13 13:28:41 +02:00
committed by GitHub
parent c061acc01c
commit 8591c2e0d1
35 changed files with 782 additions and 378 deletions

View File

@@ -7,6 +7,7 @@ import { mock } from 'jest-mock-extended';
import type { IRun } from 'n8n-workflow';
import { ActiveExecutions } from '@/active-executions';
import { DbConnection } from '@/databases/db-connection';
import { WorkflowRepository } from '@/databases/repositories/workflow.repository';
import { DeprecationService } from '@/deprecation/deprecation.service';
import { MessageEventBus } from '@/eventbus/message-event-bus/message-event-bus';
@@ -35,12 +36,9 @@ const posthogClient = mockInstance(PostHogClient);
const telemetryEventRelay = mockInstance(TelemetryEventRelay);
const externalHooks = mockInstance(ExternalHooks);
jest.mock('@/db', () => ({
init: jest.fn().mockResolvedValue(undefined),
migrate: jest.fn().mockResolvedValue(undefined),
connectionState: { connected: false },
close: jest.fn().mockResolvedValue(undefined),
}));
const dbConnection = mockInstance(DbConnection);
dbConnection.init.mockResolvedValue(undefined);
dbConnection.migrate.mockResolvedValue(undefined);
test('should start a task runner when task runners are enabled', async () => {
// arrange