queue should track and tear down workers, with tests

This commit is contained in:
2016-04-25 16:36:21 -07:00
parent 482ea68692
commit eb033d9676
2 changed files with 23 additions and 4 deletions

View File

@@ -1,6 +1,7 @@
import events from 'events';
import expect from 'expect.js';
import sinon from 'sinon';
import { noop } from 'lodash';
import elasticsearchMock from '../fixtures/elasticsearch';
import Elastique from '../../lib/index';
@@ -47,4 +48,17 @@ describe('Elastique class', function () {
});
});
describe('Registering workers', function () {
it('should keep track of workers', function () {
const queue = new Elastique('elastique', { client });
expect(queue.workers).to.eql([]);
expect(queue.workers).to.have.length(0);
queue.registerWorker('test', noop);
queue.registerWorker('test', noop);
queue.registerWorker('test2', noop);
expect(queue.workers).to.have.length(3);
});
});
});