forked from adjust/rmq
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_connection_test.go
36 lines (28 loc) · 1.62 KB
/
test_connection_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package rmq
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestTestConnection(t *testing.T) {
connection := NewTestConnection()
var _ Connection = connection // check that it implements the interface
assert.Equal(t, "rmq.TestConnection: delivery not found: things[0]", connection.GetDelivery("things", 0))
queue, err := connection.OpenQueue("things")
assert.NoError(t, err)
assert.Equal(t, "rmq.TestConnection: delivery not found: things[-1]", connection.GetDelivery("things", -1))
assert.Equal(t, "rmq.TestConnection: delivery not found: things[0]", connection.GetDelivery("things", 0))
assert.Equal(t, "rmq.TestConnection: delivery not found: things[1]", connection.GetDelivery("things", 1))
assert.NoError(t, queue.Publish("bar"))
assert.Equal(t, "bar", connection.GetDelivery("things", 0))
assert.Equal(t, "rmq.TestConnection: delivery not found: things[1]", connection.GetDelivery("things", 1))
assert.Equal(t, "rmq.TestConnection: delivery not found: things[2]", connection.GetDelivery("things", 2))
assert.NoError(t, queue.Publish("foo"))
assert.Equal(t, "bar", connection.GetDelivery("things", 0))
assert.Equal(t, "foo", connection.GetDelivery("things", 1))
assert.Equal(t, "rmq.TestConnection: delivery not found: things[2]", connection.GetDelivery("things", 2))
connection.Reset()
assert.Equal(t, "rmq.TestConnection: delivery not found: things[0]", connection.GetDelivery("things", 0))
assert.NoError(t, queue.Publish("blab"))
assert.Equal(t, "blab", connection.GetDelivery("things", 0))
assert.Equal(t, "rmq.TestConnection: delivery not found: things[1]", connection.GetDelivery("things", 1))
}