mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor(core): Set up ExecutionMetadata service (no-changelog) (#7103)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -1,18 +1,11 @@
|
||||
import { saveExecutionMetadata } from '@/WorkflowExecuteAdditionalData';
|
||||
import * as Db from '@/Db';
|
||||
import { mocked } from 'jest-mock';
|
||||
|
||||
jest.mock('@/Db', () => {
|
||||
return {
|
||||
collections: {
|
||||
ExecutionMetadata: {
|
||||
save: jest.fn(async () => []),
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
import { Container } from 'typedi';
|
||||
import { ExecutionMetadataRepository } from '@db/repositories';
|
||||
import { ExecutionMetadataService } from '@/services/executionMetadata.service';
|
||||
import { mockInstance } from '../integration/shared/utils';
|
||||
|
||||
describe('WorkflowExecuteAdditionalData', () => {
|
||||
const repository = mockInstance(ExecutionMetadataRepository);
|
||||
|
||||
test('Execution metadata is saved in a batch', async () => {
|
||||
const toSave = {
|
||||
test1: 'value1',
|
||||
@@ -20,10 +13,10 @@ describe('WorkflowExecuteAdditionalData', () => {
|
||||
};
|
||||
const executionId = '1234';
|
||||
|
||||
await saveExecutionMetadata(executionId, toSave);
|
||||
await Container.get(ExecutionMetadataService).save(executionId, toSave);
|
||||
|
||||
expect(mocked(Db.collections.ExecutionMetadata.save)).toHaveBeenCalledTimes(1);
|
||||
expect(mocked(Db.collections.ExecutionMetadata.save).mock.calls[0]).toEqual([
|
||||
expect(repository.save).toHaveBeenCalledTimes(1);
|
||||
expect(repository.save.mock.calls[0]).toEqual([
|
||||
[
|
||||
{
|
||||
execution: { id: executionId },
|
||||
|
||||
Reference in New Issue
Block a user