feat-pipelines #1

Merged
Ivan merged 25 commits from feat-pipelines into master 2021-03-24 20:50:41 +08:00
Showing only changes of commit ba0ba46a35 - Show all commits

View File

@ -155,20 +155,31 @@ describe('PipelineTasksService', () => {
it('pipeline is busy', async () => {
let remainTimes = 3;
const incr = jest
.spyOn(redisClient, 'incr')
.mockImplementation(() => remainTimes--);
let lckValue: string;
const set = jest
.spyOn(redisClient, 'set')
.mockImplementation(async (...args) => {
if (remainTimes-- > 0) {
throw new Error();
} else {
lckValue = args[3] as string;
}
});
const get = jest
.spyOn(redisClient, 'get')
.mockImplementation(async () => lckValue);
const del = jest.spyOn(redisClient, 'del');
const rpop = jest.spyOn(redisClient, 'rpop');
const decr = jest.spyOn(redisClient, 'decr');
const add = jest.spyOn(taskQueue, 'add');
await service.doNextTask(getBasePipeline());
expect(rpop).toHaveBeenCalledTimes(1);
expect(incr).toHaveBeenCalledTimes(3);
expect(decr).toHaveBeenCalledTimes(3);
expect(set).toHaveBeenCalledTimes(4);
expect(get).toHaveBeenCalledTimes(1);
expect(del).toHaveBeenCalledTimes(1);
expect(add).toHaveBeenCalledWith(getTask());
});
}, 10_000);
it('pipeline always busy and timeout', async () => {
const set = jest
.spyOn(redisClient, 'set')