ci(core): Reduce memory usage in tests (part-2) (no-changelog) (#7671)

This also gets rid of `Db.collection`, which was another source of
circular dependencies.
This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2023-11-10 15:04:26 +01:00
committed by GitHub
parent 37dd658dc5
commit 000e76e3b4
174 changed files with 892 additions and 808 deletions

View File

@@ -1,15 +1,16 @@
import type { SuperAgentTest } from 'supertest';
import type { INode, IPinData } from 'n8n-workflow';
import * as UserManagementHelpers from '@/UserManagement/UserManagementHelper';
import type { User } from '@/databases/entities/User';
import type { User } from '@db/entities/User';
import { v4 as uuid } from 'uuid';
import { RoleService } from '@/services/role.service';
import Container from 'typedi';
import type { ListQuery } from '@/requests';
import { License } from '@/License';
import { WorkflowHistoryRepository } from '@/databases/repositories';
import { WorkflowHistoryRepository } from '@db/repositories/workflowHistory.repository';
import { ActiveWorkflowRunner } from '@/ActiveWorkflowRunner';
import { mockInstance } from '../shared/mocking';
import * as utils from './shared/utils/';
import * as testDb from './shared/testDb';
import { makeWorkflow, MOCK_PINDATA } from './shared/utils/';
@@ -27,12 +28,12 @@ const testServer = utils.setupTestServer({ endpointGroups: ['workflows'] });
const { objectContaining, arrayContaining, any } = expect;
const licenseLike = utils.mockInstance(License, {
const licenseLike = mockInstance(License, {
isWorkflowHistoryLicensed: jest.fn().mockReturnValue(false),
isWithinUsersLimit: jest.fn().mockReturnValue(true),
});
const activeWorkflowRunnerLike = utils.mockInstance(ActiveWorkflowRunner);
const activeWorkflowRunnerLike = mockInstance(ActiveWorkflowRunner);
beforeAll(async () => {
owner = await createOwner();
@@ -41,7 +42,7 @@ beforeAll(async () => {
beforeEach(async () => {
jest.resetAllMocks();
await testDb.truncate(['Workflow', 'SharedWorkflow', 'Tag', WorkflowHistoryRepository]);
await testDb.truncate(['Workflow', 'SharedWorkflow', 'Tag', 'WorkflowHistory']);
licenseLike.isWorkflowHistoryLicensed.mockReturnValue(false);
});