mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(core): Port workflow history config (#14689)
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
import { GlobalConfig } from '@n8n/config';
|
||||
import { Container } from '@n8n/di';
|
||||
import { In } from '@n8n/typeorm';
|
||||
import { DateTime } from 'luxon';
|
||||
|
||||
import config from '@/config';
|
||||
import { WorkflowHistoryRepository } from '@/databases/repositories/workflow-history.repository';
|
||||
import { License } from '@/license';
|
||||
import { WorkflowHistoryManager } from '@/workflows/workflow-history.ee/workflow-history-manager.ee';
|
||||
@@ -16,19 +16,21 @@ describe('Workflow History Manager', () => {
|
||||
const license = mockInstance(License);
|
||||
let repo: WorkflowHistoryRepository;
|
||||
let manager: WorkflowHistoryManager;
|
||||
let globalConfig: GlobalConfig;
|
||||
|
||||
beforeAll(async () => {
|
||||
await testDb.init();
|
||||
repo = Container.get(WorkflowHistoryRepository);
|
||||
manager = Container.get(WorkflowHistoryManager);
|
||||
globalConfig = Container.get(GlobalConfig);
|
||||
});
|
||||
|
||||
beforeEach(async () => {
|
||||
await testDb.truncate(['Workflow']);
|
||||
jest.clearAllMocks();
|
||||
|
||||
config.set('workflowHistory.enabled', true);
|
||||
config.set('workflowHistory.pruneTime', -1);
|
||||
globalConfig.workflowHistory.enabled = true;
|
||||
globalConfig.workflowHistory.pruneTime = -1;
|
||||
|
||||
license.isWorkflowHistoryLicensed.mockReturnValue(true);
|
||||
license.getWorkflowHistoryPruneLimit.mockReturnValue(-1);
|
||||
@@ -64,7 +66,7 @@ describe('Workflow History Manager', () => {
|
||||
});
|
||||
|
||||
test('should not prune when licensed but disabled', async () => {
|
||||
config.set('workflowHistory.enabled', false);
|
||||
globalConfig.workflowHistory.enabled = false;
|
||||
await createWorkflowHistory();
|
||||
await pruneAndAssertCount();
|
||||
});
|
||||
@@ -75,7 +77,7 @@ describe('Workflow History Manager', () => {
|
||||
});
|
||||
|
||||
test('should prune when config prune time is not -1 (infinite)', async () => {
|
||||
config.set('workflowHistory.pruneTime', 24);
|
||||
globalConfig.workflowHistory.pruneTime = 24;
|
||||
await createWorkflowHistory();
|
||||
await pruneAndAssertCount(0);
|
||||
});
|
||||
@@ -88,7 +90,7 @@ describe('Workflow History Manager', () => {
|
||||
});
|
||||
|
||||
test('should only prune versions older than prune time', async () => {
|
||||
config.set('workflowHistory.pruneTime', 24);
|
||||
globalConfig.workflowHistory.pruneTime = 24;
|
||||
|
||||
const recentVersions = await createWorkflowHistory(0);
|
||||
const oldVersions = await createWorkflowHistory();
|
||||
|
||||
Reference in New Issue
Block a user