mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-20 11:22:15 +00:00
refactor(core): Make Logger a service (no-changelog) (#7494)
This commit is contained in:
committed by
GitHub
parent
db4e61ba24
commit
05586a900d
@@ -1,7 +1,5 @@
|
||||
import Container from 'typedi';
|
||||
import config from '@/config';
|
||||
import { LoggerProxy } from 'n8n-workflow';
|
||||
import { getLogger } from '@/Logger';
|
||||
import { OrchestrationMainService } from '@/services/orchestration/main/orchestration.main.service';
|
||||
import type { RedisServiceWorkerResponseObject } from '@/services/redis/RedisServiceCommands';
|
||||
import { eventBus } from '@/eventbus';
|
||||
@@ -12,6 +10,7 @@ import { handleCommandMessageMain } from '@/services/orchestration/main/handleCo
|
||||
import { OrchestrationHandlerMainService } from '@/services/orchestration/main/orchestration.handler.main.service';
|
||||
import * as helpers from '@/services/orchestration/helpers';
|
||||
import { ExternalSecretsManager } from '@/ExternalSecrets/ExternalSecretsManager.ee';
|
||||
import { Logger } from '@/Logger';
|
||||
|
||||
const os = Container.get(OrchestrationMainService);
|
||||
const handler = Container.get(OrchestrationHandlerMainService);
|
||||
@@ -33,10 +32,10 @@ const workerRestartEventbusResponse: RedisServiceWorkerResponseObject = {
|
||||
};
|
||||
|
||||
describe('Orchestration Service', () => {
|
||||
const logger = mockInstance(Logger);
|
||||
beforeAll(async () => {
|
||||
mockInstance(RedisService);
|
||||
mockInstance(ExternalSecretsManager);
|
||||
LoggerProxy.init(getLogger());
|
||||
jest.mock('ioredis', () => {
|
||||
const Redis = require('ioredis-mock');
|
||||
if (typeof Redis === 'object') {
|
||||
@@ -52,7 +51,7 @@ describe('Orchestration Service', () => {
|
||||
return new Redis(args);
|
||||
};
|
||||
});
|
||||
jest.mock('../../../src/services/redis/RedisServicePubSubPublisher', () => {
|
||||
jest.mock('@/services/redis/RedisServicePubSubPublisher', () => {
|
||||
return jest.fn().mockImplementation(() => {
|
||||
return {
|
||||
init: jest.fn(),
|
||||
@@ -62,7 +61,7 @@ describe('Orchestration Service', () => {
|
||||
};
|
||||
});
|
||||
});
|
||||
jest.mock('../../../src/services/redis/RedisServicePubSubSubscriber', () => {
|
||||
jest.mock('@/services/redis/RedisServicePubSubSubscriber', () => {
|
||||
return jest.fn().mockImplementation(() => {
|
||||
return {
|
||||
subscribeToCommandChannel: jest.fn(),
|
||||
@@ -75,8 +74,8 @@ describe('Orchestration Service', () => {
|
||||
});
|
||||
|
||||
afterAll(async () => {
|
||||
jest.mock('../../../src/services/redis/RedisServicePubSubPublisher').restoreAllMocks();
|
||||
jest.mock('../../../src/services/redis/RedisServicePubSubSubscriber').restoreAllMocks();
|
||||
jest.mock('@/services/redis/RedisServicePubSubPublisher').restoreAllMocks();
|
||||
jest.mock('@/services/redis/RedisServicePubSubSubscriber').restoreAllMocks();
|
||||
await os.shutdown();
|
||||
});
|
||||
|
||||
@@ -96,7 +95,6 @@ describe('Orchestration Service', () => {
|
||||
});
|
||||
|
||||
test('should handle command messages from others', async () => {
|
||||
jest.spyOn(LoggerProxy, 'error');
|
||||
const responseFalseId = await handleCommandMessageMain(
|
||||
JSON.stringify({
|
||||
senderId: 'test',
|
||||
@@ -106,8 +104,7 @@ describe('Orchestration Service', () => {
|
||||
expect(responseFalseId).toBeDefined();
|
||||
expect(responseFalseId!.command).toEqual('reloadLicense');
|
||||
expect(responseFalseId!.senderId).toEqual('test');
|
||||
expect(LoggerProxy.error).toHaveBeenCalled();
|
||||
jest.spyOn(LoggerProxy, 'error').mockRestore();
|
||||
expect(logger.error).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
test('should reject command messages from iteslf', async () => {
|
||||
|
||||
Reference in New Issue
Block a user