CartoDB-SQL-API/test/integration/batch/job-publisher-test.js

40 lines
1007 B
JavaScript
Raw Normal View History

'use strict';
require('../../helper');
var BATCH_SOURCE = '../../../lib/batch/';
var assert = require('../../support/assert');
var redisUtils = require('../../support/redis-utils');
var Channel = require(BATCH_SOURCE + 'pubsub/channel');
2016-10-12 00:28:46 +08:00
var JobPublisher = require(BATCH_SOURCE + 'pubsub/job-publisher');
var HOST = 'wadus';
describe('job publisher', function() {
2016-10-17 21:02:34 +08:00
var jobPublisher = new JobPublisher(redisUtils.getPool());
it('.publish() should publish in job channel', function (done) {
2016-10-17 21:02:34 +08:00
redisUtils.getPool().acquire(Channel.DB, function (err, client) {
if (err) {
return done(err);
}
client.subscribe(Channel.NAME);
client.on('message', function (channel, host) {
assert.equal(host, HOST);
2018-02-09 00:59:28 +08:00
assert.equal(channel, Channel.NAME);
client.unsubscribe(Channel.NAME);
done();
});
jobPublisher.publish(HOST);
});
});
});