2023-09-05 00:13:30 -07:00
|
|
|
import { Container } from 'typedi';
|
2023-11-10 06:04:26 -08:00
|
|
|
import { ExecutionMetadataRepository } from '@db/repositories/executionMetadata.repository';
|
2023-09-05 00:13:30 -07:00
|
|
|
import { ExecutionMetadataService } from '@/services/executionMetadata.service';
|
2023-11-10 06:04:26 -08:00
|
|
|
import { mockInstance } from '../shared/mocking';
|
2023-03-23 10:07:46 -07:00
|
|
|
|
|
|
|
describe('WorkflowExecuteAdditionalData', () => {
|
2023-09-05 00:13:30 -07:00
|
|
|
const repository = mockInstance(ExecutionMetadataRepository);
|
|
|
|
|
2023-03-23 10:07:46 -07:00
|
|
|
test('Execution metadata is saved in a batch', async () => {
|
|
|
|
const toSave = {
|
|
|
|
test1: 'value1',
|
|
|
|
test2: 'value2',
|
|
|
|
};
|
|
|
|
const executionId = '1234';
|
|
|
|
|
2023-09-05 00:13:30 -07:00
|
|
|
await Container.get(ExecutionMetadataService).save(executionId, toSave);
|
2023-03-23 10:07:46 -07:00
|
|
|
|
2023-09-05 00:13:30 -07:00
|
|
|
expect(repository.save).toHaveBeenCalledTimes(1);
|
|
|
|
expect(repository.save.mock.calls[0]).toEqual([
|
2023-03-23 10:07:46 -07:00
|
|
|
[
|
|
|
|
{
|
|
|
|
execution: { id: executionId },
|
|
|
|
key: 'test1',
|
|
|
|
value: 'value1',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
execution: { id: executionId },
|
|
|
|
key: 'test2',
|
|
|
|
value: 'value2',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
});
|