Skip to content

Commit

Permalink
adds unbind queue test
Browse files Browse the repository at this point in the history
  • Loading branch information
gbeletti committed May 8, 2022
1 parent 81f8714 commit 293137c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
12 changes: 12 additions & 0 deletions queue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

0 comments on commit 293137c

Please sign in to comment.