Skip to content

Commit

Permalink
chore(rabbitmq): add test for queue assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
fermentfan committed Nov 5, 2023
1 parent 0226314 commit da35452
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions integration/rabbitmq/e2e/configuration.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,36 @@ describe('Module Configuration', () => {
await amqpConnection.channel.deleteExchange(nonExistingExchange);
});

it("should throw an error if queue doesn't exist and `createQueueIfNotExists` is false", async () => {
try {
app = await Test.createTestingModule({
imports: [
RabbitMQModule.forRoot(RabbitMQModule, {
queues: [
{
name: nonExistingQueue,
createExchangeIfNotExists: false,
},
],
uri,
connectionInitOptions: {
wait: true,
reject: true,
timeout: 3000,
},
logger,
}),
],
}).compile();

fail(
`Queue "${nonExistingQueue}" should not exist before running this test`,
);
} catch (error) {
expect(error).toBeDefined();
}
});

it('should create a queue successfully if `createQueueIfNotExists` is true', async () => {
const spy = jest.spyOn(amqplib, 'connect');

Expand Down

0 comments on commit da35452

Please sign in to comment.