MCPcopy Create free account
hub / github.com/cloudwan/gohan / TestQueue

Function TestQueue

job/queue_test.go:25–49  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

23)
24
25func TestQueue(t *testing.T) {
26 queue := NewQueue(5)
27 for i := 0; i < 5; i++ {
28 queue.Add(NewJob(
29 func() {
30 panic("Test panic")
31 },
32 ))
33 }
34 counter := util.NewCounter(0)
35 for i := 0; i < 100; i++ {
36 queue.Add(NewJob(
37 func() {
38 counter.Add(1)
39 runtime.Gosched()
40 },
41 ))
42 }
43
44 queue.Stop()
45 var expected int64 = 100
46 if expected != counter.Value() {
47 t.Fail()
48 }
49}

Callers

nothing calls this directly

Calls 6

AddMethod · 0.95
AddMethod · 0.95
StopMethod · 0.95
ValueMethod · 0.95
NewQueueFunction · 0.85
NewJobFunction · 0.85

Tested by

no test coverage detected