refactor: Upsert workflow statistics to suppress unnecessary error messages (#5863)

This commit is contained in:
Omar Ajoue
2023-04-04 18:11:21 +02:00
committed by GitHub
parent bdcfcb2ef7
commit 2b06673b2e
2 changed files with 91 additions and 31 deletions

View File

@@ -17,7 +17,11 @@ type WorkflowStatisticsRepository = Repository<WorkflowStatistics>;
jest.mock('@/Db', () => {
return {
collections: {
WorkflowStatistics: mock<WorkflowStatisticsRepository>(),
WorkflowStatistics: mock<WorkflowStatisticsRepository>({
findOne: jest.fn(() => ({
count: 1,
})),
}),
},
};
});
@@ -101,9 +105,9 @@ describe('Events', () => {
test('should not send metrics for updated entries', async () => {
// Call the function with a fail insert, ensure update is called *and* metrics aren't sent
workflowStatisticsRepository.insert.mockImplementationOnce(() => {
throw new QueryFailedError('invalid insert', [], '');
});
workflowStatisticsRepository.findOne.mockImplementationOnce(() => ({
count: 2,
}));
const workflow = {
id: '1',
name: '',