forked from adjust/rmq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_delivery_test.go
43 lines (34 loc) · 1.03 KB
/
test_delivery_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
43
package rmq
import (
"testing"
. "github.com/adjust/gocheck"
)
func TestDeliverySuite(t *testing.T) {
TestingSuiteT(&DeliverySuite{}, t)
}
type DeliverySuite struct {
}
func (suite *DeliverySuite) TestDeliveryPayload(c *C) {
var delivery Delivery
delivery = NewTestDelivery("p23")
c.Check(delivery.Ack(), Equals, true)
c.Check(delivery.Payload(), Equals, "p23")
}
func (suite *DeliverySuite) TestDeliveryAck(c *C) {
delivery := NewTestDelivery("p")
c.Check(delivery.State, Equals, Unacked)
c.Check(delivery.Ack(), Equals, true)
c.Check(delivery.State, Equals, Acked)
c.Check(delivery.Ack(), Equals, false)
c.Check(delivery.Reject(), Equals, false)
c.Check(delivery.State, Equals, Acked)
}
func (suite *DeliverySuite) TestDeliveryReject(c *C) {
delivery := NewTestDelivery("p")
c.Check(delivery.State, Equals, Unacked)
c.Check(delivery.Reject(), Equals, true)
c.Check(delivery.State, Equals, Rejected)
c.Check(delivery.Reject(), Equals, false)
c.Check(delivery.Ack(), Equals, false)
c.Check(delivery.State, Equals, Rejected)
}