refactor(core): Use DI for WorkflowRunner (no-changelog) (#8372)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2024-01-26 13:49:39 +01:00
committed by GitHub
parent bf11c7c1bd
commit c70fa66e76
21 changed files with 215 additions and 258 deletions

View File

@@ -1,8 +1,11 @@
import type { INode } from 'n8n-workflow';
import { WorkflowExecutionService } from '@/workflows/workflowExecution.service';
import type { IWorkflowDb } from '@/Interfaces';
import { mock } from 'jest-mock-extended';
import type { WorkflowEntity } from '@db/entities/WorkflowEntity';
import type { IWorkflowDb } from '@/Interfaces';
import { WorkflowExecutionService } from '@/workflows/workflowExecution.service';
import type { WorkflowRunner } from '@/WorkflowRunner';
const webhookNode: INode = {
name: 'Webhook',
type: 'n8n-nodes-base.webhook',
@@ -47,17 +50,28 @@ const hackerNewsNode: INode = {
};
describe('WorkflowExecutionService', () => {
let workflowExecutionService: WorkflowExecutionService;
const workflowRunner = mock<WorkflowRunner>();
const workflowExecutionService = new WorkflowExecutionService(
mock(),
mock(),
mock(),
mock(),
mock(),
mock(),
workflowRunner,
);
beforeAll(() => {
workflowExecutionService = new WorkflowExecutionService(
mock(),
mock(),
mock(),
mock(),
mock(),
mock(),
);
describe('runWorkflow()', () => {
test('should call `WorkflowRunner.run()`', async () => {
const node = mock<INode>();
const workflow = mock<WorkflowEntity>({ active: true, nodes: [node] });
workflowRunner.run.mockResolvedValue('fake-execution-id');
await workflowExecutionService.runWorkflow(workflow, node, [[]], mock(), 'trigger');
expect(workflowRunner.run).toHaveBeenCalledTimes(1);
});
});
describe('selectPinnedActivatorStarter()', () => {