0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Added test coverage for graceful job queue shutdown

This commit is contained in:
Naz 2020-11-17 18:14:37 +13:00
parent 788014c8e0
commit e6e7dc93dd
2 changed files with 24 additions and 0 deletions

View file

@ -12,6 +12,7 @@ describe('Job Manager', function () {
beforeEach(function () {
logging = {
info: sinon.stub(),
warn: sinon.stub(),
error: sinon.stub()
};
});
@ -67,4 +68,18 @@ describe('Job Manager', function () {
}
});
});
describe('Shutdown', function () {
it('gracefully shuts down synchronous jobs', async function () {
const jobManager = new JobManager(logging);
jobManager.addJob(require('./jobs/timed-job'), 200);
should(jobManager.queue.idle()).be.false();
await jobManager.shutdown();
should(jobManager.queue.idle()).be.true();
});
});
});

View file

@ -0,0 +1,9 @@
const util = require('util');
const setTimeoutPromise = util.promisify(setTimeout);
const passTime = async (ms) => {
await setTimeoutPromise(ms);
return 'done';
};
module.exports = passTime;