From f09a42d45c3a297bfd9380f459ce80db5de29b82 Mon Sep 17 00:00:00 2001 From: Krzysztof Gzocha Date: Thu, 21 Feb 2019 18:56:24 +0100 Subject: [PATCH] Using interfaces in tests --- integration_test.go | 6 +++--- reconnect_test.go | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/integration_test.go b/integration_test.go index b4a2958c..6fedb12d 100644 --- a/integration_test.go +++ b/integration_test.go @@ -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 } @@ -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 { @@ -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 { diff --git a/reconnect_test.go b/reconnect_test.go index e67325c2..8905de02 100644 --- a/reconnect_test.go +++ b/reconnect_test.go @@ -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 @@ -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