-
Notifications
You must be signed in to change notification settings - Fork 207
/
test_delivery_test.go
48 lines (39 loc) · 1.28 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
44
45
46
47
48
package rmq
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestDeliveryPayload(t *testing.T) {
var delivery Delivery
delivery = NewTestDelivery("p23")
assert.NoError(t, delivery.Ack())
assert.Equal(t, "p23", delivery.Payload())
}
func TestDeliveryAck(t *testing.T) {
delivery := NewTestDelivery("p")
assert.Equal(t, Unacked, delivery.State)
assert.NoError(t, delivery.Ack())
assert.Equal(t, Acked, delivery.State)
assert.Equal(t, ErrorNotFound, delivery.Ack())
assert.Equal(t, ErrorNotFound, delivery.Reject())
assert.Equal(t, Acked, delivery.State)
}
func TestDeliveryReject(t *testing.T) {
delivery := NewTestDelivery("p")
assert.Equal(t, Unacked, delivery.State)
assert.NoError(t, delivery.Reject())
assert.Equal(t, Rejected, delivery.State)
assert.Equal(t, ErrorNotFound, delivery.Reject())
assert.Equal(t, ErrorNotFound, delivery.Ack())
assert.Equal(t, Rejected, delivery.State)
}
func TestDeliveryPush(t *testing.T) {
delivery := NewTestDelivery("p")
assert.Equal(t, Unacked, delivery.State)
assert.NoError(t, delivery.Push())
assert.Equal(t, Pushed, delivery.State)
assert.Equal(t, ErrorNotFound, delivery.Push())
assert.Equal(t, ErrorNotFound, delivery.Reject())
assert.Equal(t, ErrorNotFound, delivery.Ack())
assert.Equal(t, Pushed, delivery.State)
}