-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathrequeue_message_test.go
More file actions
31 lines (24 loc) · 827 Bytes
/
requeue_message_test.go
File metadata and controls
31 lines (24 loc) · 827 Bytes
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
package requeue_test
import (
"testing"
"github.com/nickpoorman/nats-requeue/flatbuf"
"github.com/nickpoorman/nats-requeue/protocol"
"github.com/stretchr/testify/assert"
)
func TestRequeueMessage_FlatbufMutate(t *testing.T) {
msg := protocol.DefaultRequeueMessage()
msg.Retries = 5
msg.TTL = 10000
msg.Delay = 20000
msg.BackoffStrategy = protocol.BackoffStrategy_Exponential
msg.OriginalSubject = "foo.bar"
msg.OriginalPayload = []byte("my awesome message")
msgBytes := msg.Bytes()
fb := flatbuf.GetRootAsRequeueMessage(msgBytes, 0)
assert.Equal(t, fb.Retries(), uint64(5))
assert.True(t, fb.MutateRetries(4))
assert.Equal(t, fb.Retries(), uint64(4))
// Assert that fb was modifying the underlying bytes.
fb2 := flatbuf.GetRootAsRequeueMessage(msgBytes, 0)
assert.Equal(t, fb2.Retries(), uint64(4))
}