Skip to content

Commit

Permalink
Using interfaces in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Gzocha committed Apr 3, 2019
1 parent 4efaa87 commit f09a42d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,7 @@ func TestIntegrationChannelClosing(t *testing.T) {
// This function is run on every channel after it is successfully
// opened. It can do something to verify something. It should be
// quick; many channels may be opened!
f := func(t *testing.T, c *Channel) {
f := func(t *testing.T, c ChannelInterface) {
return
}

Expand Down Expand Up @@ -497,7 +497,7 @@ func TestIntegrationChannelClosing(t *testing.T) {

// multiple channels
for _, n := range []int{2, 4, 8, 16, 32, 64, 128, 256} {
channels := make([]*Channel, n)
channels := make([]ChannelInterface, n)
for i := 0; i < n; i++ {
var err error
if channels[i], err = c.Channel(); err != nil {
Expand Down Expand Up @@ -1807,7 +1807,7 @@ func integrationConnection(t *testing.T, name string) *Connection {
}

// Returns a connection, channel and declares a queue when the AMQP_URL is in the environment
func integrationQueue(t *testing.T, name string) (*Connection, *Channel) {
func integrationQueue(t *testing.T, name string) (*Connection, ChannelInterface) {
if conn := integrationConnection(t, name); conn != nil {
if channel, err := conn.Channel(); err == nil {
if _, err = channel.QueueDeclare(name, false, true, false, false, nil); err == nil {
Expand Down
4 changes: 2 additions & 2 deletions reconnect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

// Every connection should declare the topology they expect
func setup(url, queue string) (*amqp.Connection, *amqp.Channel, error) {
func setup(url, queue string) (amqp.ConnectionInterface, amqp.ChannelInterface, error) {
conn, err := amqp.Dial(url)
if err != nil {
return nil, nil, err
Expand All @@ -26,7 +26,7 @@ func setup(url, queue string) (*amqp.Connection, *amqp.Channel, error) {
return conn, ch, nil
}

func consume(url, queue string) (*amqp.Connection, <-chan amqp.Delivery, error) {
func consume(url, queue string) (amqp.ConnectionInterface, <-chan amqp.Delivery, error) {
conn, ch, err := setup(url, queue)
if err != nil {
return nil, nil, err
Expand Down

0 comments on commit f09a42d

Please sign in to comment.