@emartech/rabbitmq-client
Advanced tools
Comparing version 2.5.0 to 2.6.0
@@ -44,3 +44,3 @@ { | ||
}, | ||
"version": "2.5.0" | ||
"version": "2.6.0" | ||
} |
@@ -101,2 +101,10 @@ 'use strict'; | ||
async waitForConfirms() { | ||
if (this._config.useConfirmChannel) { | ||
return await this._channel.waitForConfirms(); | ||
} | ||
throw new Error('Waiting for confirmation is only supported with confirmation channels'); | ||
} | ||
async purge() { | ||
@@ -103,0 +111,0 @@ await this._channel.purgeQueue(this.queueName); |
@@ -44,3 +44,4 @@ 'use strict'; | ||
purgeQueue: sandbox.stub().resolves(true), | ||
assertQueue: sandbox.stub().resolves(true) | ||
assertQueue: sandbox.stub().resolves(true), | ||
waitForConfirms: sandbox.stub().resolves(true) | ||
}); | ||
@@ -261,2 +262,19 @@ | ||
it('#waitForConfirms should wait for message acks by calling waitForConfirms on the channel', async function() { | ||
const rabbitMq = new RabbitMq(config, 'some-queue', 'confirmChannel'); | ||
await rabbitMq.connect(); | ||
await rabbitMq.createChannel(); | ||
await rabbitMq.waitForConfirms(); | ||
expect(channelMock.waitForConfirms).to.have.been.called; | ||
}); | ||
it('#waitForConfirms should throw an exception when we are not using confirmChannel', async function() { | ||
await rabbitMq.connect(); | ||
await rabbitMq.createChannel(); | ||
await expect(rabbitMq.waitForConfirms()) | ||
.to.be.rejectedWith('Waiting for confirmation is only supported with confirmation channels'); | ||
}); | ||
describe('with dead channel', () => { | ||
@@ -263,0 +281,0 @@ |
36699
929