Skip to content

Commit d10e91c

Browse files
rabbitmq
1 parent afe03c8 commit d10e91c

File tree

6 files changed

+29
-22
lines changed

6 files changed

+29
-22
lines changed

docs/modules/cockroachdb.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ These examples use the following libraries:
1313
- [pg](https://www.npmjs.com/package/pg)
1414

1515
npm install pg
16-
npm install @types/pg
16+
npm install @types/pg --save-dev
1717

1818
Choose an image from the [container registry](https://hub.docker.com/r/cockroachdb/cockroach) and substitute `IMAGE`.
1919

docs/modules/mockserver.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ These examples use the following libraries:
1717
- [superagent](https://www.npmjs.com/package/superagent)
1818

1919
npm install superagent
20-
npm install @types/superagent
20+
npm install @types/superagent --save-dev
2121

2222
Choose an image from the [container registry](https://hub.docker.com/r/mockserver/mockserver) and substitute `IMAGE`.
2323

docs/modules/mssqlserver.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ These examples use the following libraries:
1313
- [mssql](https://www.npmjs.com/package/mssql)
1414

1515
npm install mssql
16-
npm install @types/mssql
16+
npm install @types/mssql --save-dev
1717

1818
Choose an image from the [container registry](https://mcr.microsoft.com/en-us/artifact/mar/mssql/server) and substitute `IMAGE`.
1919

docs/modules/postgresql.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ These examples use the following libraries:
1313
- [pg](https://www.npmjs.com/package/pg)
1414

1515
npm install pg
16-
npm install @types/pg
16+
npm install @types/pg --save-dev
1717

1818
Choose an image from the [container registry](https://hub.docker.com/_/postgres) and substitute `IMAGE`.
1919

docs/modules/rabbitmq.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
# RabbitMQ Module
2-
3-
[RabbitMQ](https://www.rabbitmq.com/) is a reliable and mature messaging and streaming broker, which is easy to deploy on cloud environments, on-premises, and on your local machine. It is currently used by millions worldwide.
1+
# RabbitMQ
42

53
## Install
64

@@ -10,14 +8,23 @@ npm install @testcontainers/rabbitmq --save-dev
108

119
## Examples
1210

13-
<!--codeinclude-->
14-
[Connect:](../../packages/modules/rabbitmq/src/rabbitmq-container.test.ts) inside_block:start
15-
<!--/codeinclude-->
11+
These examples use the following libraries:
12+
13+
- [amqplib](https://www.npmjs.com/package/amqplib)
14+
15+
npm install amqplib
16+
npm install @types/amqplib --save-dev
17+
18+
Choose an image from the [container registry](https://hub.docker.com/_/rabbitmq) and substitute `IMAGE`.
19+
20+
### Produce/consume a message
1621

1722
<!--codeinclude-->
18-
[Set credentials:](../../packages/modules/rabbitmq/src/rabbitmq-container.test.ts) inside_block:credentials
23+
[](../../packages/modules/rabbitmq/src/rabbitmq-container.test.ts) inside_block:pubsub
1924
<!--/codeinclude-->
2025

26+
### With credentials
27+
2128
<!--codeinclude-->
22-
[Publish and subscribe:](../../packages/modules/rabbitmq/src/rabbitmq-container.test.ts) inside_block:pubsub
29+
[](../../packages/modules/rabbitmq/src/rabbitmq-container.test.ts) inside_block:credentials
2330
<!--/codeinclude-->

packages/modules/rabbitmq/src/rabbitmq-container.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ const IMAGE = getImage(__dirname);
77
describe("RabbitMQContainer", { timeout: 240_000 }, () => {
88
// start {
99
it("should start, connect and close", async () => {
10-
await using rabbitMQContainer = await new RabbitMQContainer(IMAGE).start();
10+
await using container = await new RabbitMQContainer(IMAGE).start();
1111

12-
const connection = await amqp.connect(rabbitMQContainer.getAmqpUrl());
12+
const connection = await amqp.connect(container.getAmqpUrl());
1313
await connection.close();
1414
});
1515
// }
1616

17-
// credentials {
1817
it("different username and password", async () => {
18+
// credentials {
1919
const USER = "user";
2020
const PASSWORD = "password";
2121

22-
await using rabbitMQContainer = await new RabbitMQContainer(IMAGE)
22+
await using container = await new RabbitMQContainer(IMAGE)
2323
.withEnvironment({
2424
RABBITMQ_DEFAULT_USER: USER,
2525
RABBITMQ_DEFAULT_PASS: PASSWORD,
@@ -29,21 +29,21 @@ describe("RabbitMQContainer", { timeout: 240_000 }, () => {
2929
const connection = await amqp.connect({
3030
username: USER,
3131
password: PASSWORD,
32-
port: rabbitMQContainer.getMappedPort(5672),
32+
port: container.getMappedPort(5672),
3333
});
34+
// }
3435

3536
await connection.close();
3637
});
37-
// }
3838

39-
// pubsub {
4039
it("test publish and subscribe", async () => {
40+
// pubsub {
4141
const QUEUE = "test";
4242
const PAYLOAD = "Hello World";
4343

44-
await using rabbitMQContainer = await new RabbitMQContainer(IMAGE).start();
45-
const connection = await amqp.connect(rabbitMQContainer.getAmqpUrl());
44+
await using container = await new RabbitMQContainer(IMAGE).start();
4645

46+
const connection = await amqp.connect(container.getAmqpUrl());
4747
const channel = await connection.createChannel();
4848
await channel.assertQueue(QUEUE);
4949

@@ -58,6 +58,6 @@ describe("RabbitMQContainer", { timeout: 240_000 }, () => {
5858

5959
await channel.close();
6060
await connection.close();
61+
// }
6162
}, 20_000);
62-
// }
6363
});

0 commit comments

Comments
 (0)