From 293137c46e1096fa464bcc342120b481243abd0d Mon Sep 17 00:00:00 2001 From: gbeletti Date: Sun, 8 May 2022 18:45:36 -0300 Subject: [PATCH] adds unbind queue test --- connection_test.go | 2 ++ go.mod | 1 + queue_test.go | 12 ++++++++++++ 3 files changed, 15 insertions(+) diff --git a/connection_test.go b/connection_test.go index 803c7af..a06ee3a 100644 --- a/connection_test.go +++ b/connection_test.go @@ -35,6 +35,8 @@ func TestRabbit(t *testing.T) { createExchangeTest(t, rabbit, exchange, "direct") bindQueueTest(t, rabbit, exchange, queue) publishAndConsume(t, ctx, rabbit, exchange, queue, msg) + unbindQueueTest(t, rabbit, exchange, queue) + publishAndConsume(t, ctx, rabbit, "", queue, msg) if *waitFlag { t.Logf("waiting 60 seconds. Go to %s for rabbit UI", uiURL) time.Sleep(time.Second * 60) diff --git a/go.mod b/go.mod index 9b06eb4..0ba2cb8 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/gbeletti/rabbitmq go 1.18 require ( + github.com/google/go-cmp v0.5.5 github.com/rabbitmq/amqp091-go v1.3.4 github.com/testcontainers/testcontainers-go v0.13.0 ) diff --git a/queue_test.go b/queue_test.go index eaba5bd..cc3c4ac 100644 --- a/queue_test.go +++ b/queue_test.go @@ -34,3 +34,15 @@ func bindQueueTest(t *testing.T, rabbit rabbitmq.QueueBinder, exchange, queue st t.Errorf("exchange [%s] queue [%s] error binding queue: %s\n", exchange, queue, err) } } + +func unbindQueueTest(t *testing.T, rabbit rabbitmq.QueueBinder, exchange, queue string) { + config := rabbitmq.ConfigBindQueue{ + QueueName: queue, + RoutingKey: queue, + Exchange: exchange, + } + err := rabbit.UnbindQueueExchange(config) + if err != nil { + t.Errorf("exchange [%s] queue [%s] error unbinding queue: %s\n", exchange, queue, err) + } +}