Skip to content

Commit 41fab16

Browse files
committed
feat: #89 Adding AMQP/RabbitMQ support for mocking async messages
Signed-off-by: Laurent Broudoux <laurent.broudoux@gmail.com>
1 parent 530b2f9 commit 41fab16

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

ensemble/async/async.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ func WithKafkaConnection(connection kafka.Connection) testcontainers.CustomizeRe
137137
}
138138
}
139139

140-
// WithKafkaConnection connects the MicrocksAsyncMinionContainer to a MQTT broker to allow MQTT messages mocking.
140+
// WithMQTTConnection connects the MicrocksAsyncMinionContainer to a MQTT broker to allow MQTT messages mocking.
141141
func WithMQTTConnection(connection generic.Connection) testcontainers.CustomizeRequestOption {
142142
return func(req *testcontainers.GenericContainerRequest) error {
143143
if req.Env == nil {
@@ -152,6 +152,21 @@ func WithMQTTConnection(connection generic.Connection) testcontainers.CustomizeR
152152
}
153153
}
154154

155+
// WithAMQPConnection connects the MicrocksAsyncMinionContainer to an AMQP/RabbitMQ broker to allow MQTT messages mocking.
156+
func WithAMQPConnection(connection generic.Connection) testcontainers.CustomizeRequestOption {
157+
return func(req *testcontainers.GenericContainerRequest) error {
158+
if req.Env == nil {
159+
req.Env = make(map[string]string)
160+
}
161+
req.Env["AMQP_SERVER"] = connection.Server
162+
req.Env["AMQP_USERNAME"] = connection.Username
163+
req.Env["AMQP_PASSWORD"] = connection.Password
164+
addProtocol(req, "AMQP")
165+
166+
return nil
167+
}
168+
}
169+
155170
// WSMockEndpoint gets the exposed mock endpoints for a WebSocket Service.
156171
func (container *MicrocksAsyncMinionContainer) WSMockEndpoint(ctx context.Context, service, version, operationName string) (string, error) {
157172
// Get the container host.

ensemble/ensemble.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,14 @@ func WithMQTTConnection(connection generic.Connection) Option {
293293
}
294294
}
295295

296+
// WithAMQPConnection configures a connection to an AMQP/RabbitMQ Broker.
297+
func WithAMQPConnection(connection generic.Connection) Option {
298+
return func(e *MicrocksContainersEnsemble) error {
299+
e.asyncMinionContainerOptions.Add(async.WithAMQPConnection(connection))
300+
return nil
301+
}
302+
}
303+
296304
// WithSecret creates a new secret.
297305
func WithSecret(s client.Secret) Option {
298306
return func(e *MicrocksContainersEnsemble) error {

0 commit comments

Comments
 (0)