Skip to content

Commit

Permalink
feat: add support for purging queues
Browse files Browse the repository at this point in the history
  • Loading branch information
arobson committed Feb 17, 2018
1 parent a460c71 commit 19a678d
Show file tree
Hide file tree
Showing 8 changed files with 524 additions and 301 deletions.
287 changes: 0 additions & 287 deletions spec/.eslintrc.js

This file was deleted.

33 changes: 33 additions & 0 deletions spec/behavior/queueFsm.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ function channelFn (options) {
define: noOp,
destroy: noOp,
finalize: noOp,
purge: noOp,
release: noOp,
getMessageCount: noOp,
subscribe: noOp,
Expand Down Expand Up @@ -65,6 +66,12 @@ describe('Queue FSM', function () {
});
});

describe('when purging in failed state', function () {
it('should reject purge with an error', function () {
return queue.purge().should.be.rejectedWith(/nope/);
});
});

describe('when checking in failed state', function () {
it('should reject check with an error', function () {
return queue.check().should.be.rejectedWith(/nope/);
Expand Down Expand Up @@ -122,6 +129,32 @@ describe('Queue FSM', function () {
it('should change options.subscribe to true', function () {
options.subscribe.should.equal(true);
});

it('should be in subscribed state', function () {
queue.state.should.equal('subscribed');
});
});

describe('when purging in ready state', function () {
before(function () {
channelMock
.expects('purge')
.once()
.resolves(10);

channelMock
.expects('subscribe')
.once()
.resolves(true);
});

it('should resolve purge without error and resubscribe', function (done) {
queue.on('subscribed', function () {
queue.state.should.equal('subscribed');
done();
});
queue.purge().should.eventually.equal(10);
});
});

describe('when checking after subscribed state', function () {
Expand Down
Loading

0 comments on commit 19a678d

Please sign in to comment.