-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeadletters_test.go
More file actions
52 lines (43 loc) · 845 Bytes
/
deadletters_test.go
File metadata and controls
52 lines (43 loc) · 845 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package lasr
import (
"bytes"
"context"
"testing"
"time"
)
func TestDeadLetters(t *testing.T) {
q, cleanup := newQ(t, WithDeadLetters())
defer cleanup()
msg := []byte("foo")
id, err := q.Send(msg)
if err != nil {
t.Fatal(err)
}
idb, err := id.MarshalBinary()
if err != nil {
t.Fatal(err)
}
m, err := q.Receive(context.Background())
if err != nil {
t.Fatal(err)
}
if err := m.Nack(false); err != nil {
t.Fatal(err)
}
d, err := DeadLetters(q)
if err != nil {
t.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()
m, err = d.Receive(ctx)
if err != nil {
t.Fatal(err)
}
if !bytes.Equal(m.Body, msg) {
t.Errorf("bad body: %q", string(m.Body))
}
if got, want := m.ID, idb; !bytes.Equal(got, want) {
t.Errorf("bad id: got %v, want %v", got, want)
}
}