CartoDB-SQL-API/test/unit/batch/job-queue-test.js

52 lines
1.6 KiB
JavaScript
Raw Normal View History

2018-10-24 21:42:33 +08:00
'use strict';
var JobQueue = require('../../../lib/batch/job-queue');
var assert = require('assert');
describe('batch API job queue', function () {
beforeEach(function () {
this.metadataBackend = {
redisCmd: function () {
2019-12-24 01:19:08 +08:00
var callback = arguments[arguments.length - 1];
process.nextTick(function () {
callback(null, 'irrelevantJob');
});
},
redisMultiCmd: function () {
2019-12-24 01:19:08 +08:00
var callback = arguments[arguments.length - 1];
process.nextTick(function () {
callback(null, 'irrelevantJob');
});
}
};
this.jobPublisher = {
publish: function () {}
};
this.logger = {
debug: function () {}
2019-04-04 21:16:44 +08:00
};
this.jobQueue = new JobQueue(this.metadataBackend, this.jobPublisher, this.logger);
});
2016-01-23 02:31:25 +08:00
it('.enqueue() should enqueue the provided job', function (done) {
this.jobQueue.enqueue('irrelevantJob', 'irrelevantHost', function (err) {
assert.ok(!err);
done();
});
});
2016-01-23 02:31:25 +08:00
it('.dequeue() should dequeue the next job', function (done) {
this.jobQueue.dequeue('irrelevantHost', function (err) {
assert.ok(!err);
done();
});
});
2016-01-23 02:31:25 +08:00
it('.enqueueFirst() should dequeue the next job', function (done) {
this.jobQueue.enqueueFirst('irrelevantJob', 'irrelevantHost', function (err) {
2016-01-23 02:31:25 +08:00
assert.ok(!err);
done();
});
});
});