Skip to content

Commit

Permalink
tests/ExampleConnection_reconnect: close connection on termination
Browse files Browse the repository at this point in the history
ExampleConnection_reconnect was not closing the opened connection on
termination. This caused the goleak checker to complain about a leaked
heartbeat go routine.

Close the connection.
  • Loading branch information
fho committed Apr 19, 2022
1 parent 49f3bbf commit 221de11
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion reconnect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,12 @@ func ExampleConnection_reconnect() {
// between reconnects, shares the same topology as the consumer. If we rather
// sent all messages up front, the first consumer would receive every message.
// We would rather show how the messages are not lost between reconnects.
_, pub, err := setup(url, queue)
con, pub, err := setup(url, queue)
if err != nil {
fmt.Println("err publisher setup:", err)
return
}
defer con.Close()

// Purge the queue from the publisher side to establish initial state
if _, err := pub.QueuePurge(queue, false); err != nil {
Expand Down

0 comments on commit 221de11

Please sign in to comment.