CartoDB-SQL-API/test/unit/batch/job-publisher-test.js
Daniel García Aubert 0c92fcaf96 Node.js 12 support:
- Update `gc-stats` to version 1.4.0
- Replace `zipfile` -> `adm-zip`
- Update `libxmljs` to version 0.19.7
- Update `sqlite` to version 4.2.0
- Adapted pool acquires to the new version of `cartodb-redis`
- Adapted test to use `adm-zip`
2020-05-18 11:32:41 +02:00

41 lines
1.2 KiB
JavaScript

'use strict';
var Channel = require('../../../lib/batch/pubsub/channel');
var JobPublisher = require('../../../lib/batch/pubsub/job-publisher');
var assert = require('assert');
describe('batch API job publisher', function () {
beforeEach(function () {
var self = this;
this.host = 'irrelevantHost';
this.redis = {
createClient: function () {
return this;
},
publish: function () {
var isValidFirstArg = arguments[0] === Channel.NAME;
var isValidSecondArg = arguments[1] === self.host;
self.redis.publishIsCalledWithValidArgs = isValidFirstArg && isValidSecondArg;
},
on: function () {},
ping: function (cb) {
cb();
}
};
this.pool = {
acquire: function (db) {
return Promise.resolve(self.redis);
}
};
this.jobPublisher = new JobPublisher(this.pool);
});
it('.publish() should publish new messages', function () {
this.jobPublisher.publish(this.host);
setImmediate(() => {
assert.ok(this.redis.publishIsCalledWithValidArgs);
});
});
});