MCPcopy Create free account
hub / github.com/RTradeLtd/Lens / TestQueue_Queue

Function TestQueue_Queue

engine/queue/queue_test.go:17–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

15}
16
17func TestQueue_Queue(t *testing.T) {
18 type args struct {
19 item *Item
20 }
21 tests := []struct {
22 name string
23 args args
24 wantClosed bool
25 wantErr bool
26 }{
27 {"invalid item", args{nil}, false, true},
28 {"closed queue", args{&Item{Key: "asdf"}}, true, true},
29 {"ok", args{&Item{Key: "asdf"}}, false, false},
30 }
31 for _, tt := range tests {
32 t.Run(tt.name, func(t *testing.T) {
33 var q = New(zaptest.NewLogger(t).Sugar(), nil, nil, Options{
34 Rate: 500 * time.Millisecond,
35 BatchSize: 1,
36 })
37 go q.Run()
38 if tt.wantClosed {
39 q.Close()
40 }
41 time.Sleep(500 * time.Millisecond)
42 if err := q.Queue(tt.args.item); (err != nil) != tt.wantErr {
43 t.Errorf("Queue.Queue() error = %v, wantErr %v", err, tt.wantErr)
44 }
45 time.Sleep(time.Second)
46 q.Close()
47 })
48 }
49}
50
51func TestQueue_IsStopped(t *testing.T) {
52 var q = New(zaptest.NewLogger(t).Sugar(), nil, nil, Options{

Callers

nothing calls this directly

Calls 4

QueueMethod · 0.80
NewFunction · 0.70
CloseMethod · 0.65
RunMethod · 0.45

Tested by

no test coverage detected