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:
parent
788014c8e0
commit
e6e7dc93dd
2 changed files with 24 additions and 0 deletions
|
@ -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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
9
ghost/job-manager/test/jobs/timed-job.js
Normal file
9
ghost/job-manager/test/jobs/timed-job.js
Normal 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;
|
Loading…
Add table
Reference in a new issue