mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-21 11:49:59 +00:00
refactor(core): Use DI for eventBus code - Part 1 (no-changelog) (#8434)
This commit is contained in:
committed by
GitHub
parent
3cc0f81c02
commit
7c49004018
@@ -2,7 +2,7 @@ import Container from 'typedi';
|
||||
import config from '@/config';
|
||||
import { OrchestrationService } from '@/services/orchestration.service';
|
||||
import type { RedisServiceWorkerResponseObject } from '@/services/redis/RedisServiceCommands';
|
||||
import { eventBus } from '@/eventbus';
|
||||
import { MessageEventBus } from '@/eventbus';
|
||||
import { RedisService } from '@/services/redis.service';
|
||||
import { handleWorkerResponseMessageMain } from '@/services/orchestration/main/handleWorkerResponseMessageMain';
|
||||
import { handleCommandMessageMain } from '@/services/orchestration/main/handleCommandMessageMain';
|
||||
@@ -37,9 +37,11 @@ const workerRestartEventbusResponse: RedisServiceWorkerResponseObject = {
|
||||
describe('Orchestration Service', () => {
|
||||
const logger = mockInstance(Logger);
|
||||
mockInstance(Push);
|
||||
mockInstance(RedisService);
|
||||
mockInstance(ExternalSecretsManager);
|
||||
const eventBus = mockInstance(MessageEventBus);
|
||||
|
||||
beforeAll(async () => {
|
||||
mockInstance(RedisService);
|
||||
mockInstance(ExternalSecretsManager);
|
||||
jest.mock('ioredis', () => {
|
||||
const Redis = require('ioredis-mock');
|
||||
if (typeof Redis === 'object') {
|
||||
@@ -110,8 +112,7 @@ describe('Orchestration Service', () => {
|
||||
expect(logger.error).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('should reject command messages from iteslf', async () => {
|
||||
jest.spyOn(eventBus, 'restart');
|
||||
test('should reject command messages from itself', async () => {
|
||||
const response = await handleCommandMessageMain(
|
||||
JSON.stringify({ ...workerRestartEventbusResponse, senderId: queueModeId }),
|
||||
);
|
||||
@@ -119,7 +120,6 @@ describe('Orchestration Service', () => {
|
||||
expect(response!.command).toEqual('restartEventBus');
|
||||
expect(response!.senderId).toEqual(queueModeId);
|
||||
expect(eventBus.restart).not.toHaveBeenCalled();
|
||||
jest.spyOn(eventBus, 'restart').mockRestore();
|
||||
});
|
||||
|
||||
test('should send command messages', async () => {
|
||||
|
||||
Reference in New Issue
Block a user