Skip to content

Commit

Permalink
adding integration test for issue 11 (rabbitmq#50)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniele Palaia <[email protected]>
  • Loading branch information
DanielePalaia and Daniele Palaia committed Mar 25, 2022
1 parent 3b21050 commit f781c65
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

//go:build integration
// +build integration

package amqp091
Expand Down Expand Up @@ -1909,6 +1910,31 @@ func assertConsumeBody(t *testing.T, messages <-chan Delivery, want []byte) (msg
return msg
}

// https://github.com/rabbitmq/amqp091-go/issues/11
func TestShouldNotWaitAfterConnectionClosedNewChannelCreatedIssue11(t *testing.T) {
conn := integrationConnection(t, "TestShouldNotWaitAfterConnectionClosedNewChannelCreatedIssue11")
ch, err := conn.Channel()
if err != nil {
t.Fatalf("channel error: %v", err)
}

conn.NotifyClose(make(chan *Error, 1))

_, err = ch.PublishWithDeferredConfirm("issue11", "issue11", false, false, Publishing{Body: []byte("abc")})
if err != nil {
t.Fatalf("PublishWithDeferredConfirm error: %v", err)
}

ch.Close()
conn.Close()

ch, err = conn.Channel()
if err == nil {
t.Fatalf("Opening a channel from a closed connection should not block but returning an error %v", err)
}

}

// Pulls out the CRC and verifies the remaining content against the CRC
func assertMessageCrc32(t *testing.T, msg []byte, assert string) {
size := binary.BigEndian.Uint32(msg[:4])
Expand Down

0 comments on commit f781c65

Please sign in to comment.