-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathqueue_test.go
More file actions
34 lines (29 loc) · 730 Bytes
/
queue_test.go
File metadata and controls
34 lines (29 loc) · 730 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
package backlite
import (
"context"
"fmt"
"strings"
"testing"
)
func TestQueue_CannotDecode(t *testing.T) {
q := NewQueue[testTask](func(_ context.Context, _ testTask) error {
return nil
})
err := q.Process(context.Background(), []byte{1, 2, 3})
if err == nil {
t.Error("Process should have failed")
}
}
func TestQueues_GetUnregisteredQueuePanics(t *testing.T) {
s := &queues{}
defer func() {
if r := recover(); r == nil {
t.Errorf("Should be panicking, but it didn't")
} else {
if msg, ok := r.(string); !ok || !strings.Contains(msg, fmt.Sprintf("queue '%s' not registered", testTask{}.Config().Name)) {
t.Errorf("Unexpected panic value: %v", r)
}
}
}()
s.get(testTask{}.Config().Name)
}