CartoDB-SQL-API/test/unit/batch/job_publisher.js
Daniel García Aubert 74d83a457e Now batch publisher sends a ping to server before publishing and create a new connection if error.
Batch publisher and subscriber logs (if debug enabled) both outcoming and incoming messages to give more visibility.
2016-07-07 10:44:17 +02:00

32 lines
987 B
JavaScript

var JobPublisher = require('../../../batch/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] === 'batch:hosts';
var isValidSecondArg = arguments[1] === self.host;
self.redis.publishIsCalledWithValidArgs = isValidFirstArg && isValidSecondArg;
},
on: function () {},
ping: function (cb) {
cb();
}
};
this.jobPublisher = new JobPublisher(this.redis);
});
it('.publish() should publish new messages', function () {
this.jobPublisher.publish(this.host);
assert.ok(this.redis.publishIsCalledWithValidArgs);
});
});