refactor(core): Make PruningService.init and WaitTracker.init consistent (no-changelog) (#9761)

This commit is contained in:
Iván Ovejero
2024-06-17 12:49:40 +02:00
committed by GitHub
parent 7c70b782a1
commit f7352b6a8f
5 changed files with 43 additions and 30 deletions

View File

@@ -34,7 +34,8 @@ describe('WaitTracker', () => {
});
describe('init()', () => {
it('should query DB for waiting executions', async () => {
it('should query DB for waiting executions if leader', async () => {
jest.spyOn(orchestrationService, 'isLeader', 'get').mockReturnValue(true);
executionRepository.getWaitingExecutions.mockResolvedValue([execution]);
waitTracker.init();
@@ -42,6 +43,14 @@ describe('WaitTracker', () => {
expect(executionRepository.getWaitingExecutions).toHaveBeenCalledTimes(1);
});
it('if follower, should do nothing', () => {
executionRepository.getWaitingExecutions.mockResolvedValue([]);
waitTracker.init();
expect(executionRepository.findSingleExecution).not.toHaveBeenCalled();
});
it('if no executions to start, should do nothing', () => {
executionRepository.getWaitingExecutions.mockResolvedValue([]);