forked from adjust/rmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_connection_test.go
42 lines (32 loc) · 1.7 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
37
38
39
40
41
42
package rmq
import (
"testing"
. "github.com/adjust/gocheck"
)
func TestConnectionSuite(t *testing.T) {
TestingSuiteT(&ConnectionSuite{}, t)
}
type ConnectionSuite struct{}
func (suite *ConnectionSuite) TestConnection(c *C) {
connection := NewTestConnection()
var conn Connection
c.Check(connection, Implements, &conn)
c.Check(connection.GetDelivery("things", 0), Equals, "rmq.TestConnection: delivery not found: things[0]")
queue := connection.OpenQueue("things")
c.Check(connection.GetDelivery("things", -1), Equals, "rmq.TestConnection: delivery not found: things[-1]")
c.Check(connection.GetDelivery("things", 0), Equals, "rmq.TestConnection: delivery not found: things[0]")
c.Check(connection.GetDelivery("things", 1), Equals, "rmq.TestConnection: delivery not found: things[1]")
c.Check(queue.Publish("bar"), Equals, true)
c.Check(connection.GetDelivery("things", 0), Equals, "bar")
c.Check(connection.GetDelivery("things", 1), Equals, "rmq.TestConnection: delivery not found: things[1]")
c.Check(connection.GetDelivery("things", 2), Equals, "rmq.TestConnection: delivery not found: things[2]")
c.Check(queue.Publish("foo"), Equals, true)
c.Check(connection.GetDelivery("things", 0), Equals, "bar")
c.Check(connection.GetDelivery("things", 1), Equals, "foo")
c.Check(connection.GetDelivery("things", 2), Equals, "rmq.TestConnection: delivery not found: things[2]")
connection.Reset()
c.Check(connection.GetDelivery("things", 0), Equals, "rmq.TestConnection: delivery not found: things[0]")
c.Check(queue.Publish("blab"), Equals, true)
c.Check(connection.GetDelivery("things", 0), Equals, "blab")
c.Check(connection.GetDelivery("things", 1), Equals, "rmq.TestConnection: delivery not found: things[1]")
}