MCPcopy Create free account
hub / github.com/LyricTian/queue / TestSyncQueue

Function TestSyncQueue

chan_queue_test.go:30–48  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

28}
29
30func TestSyncQueue(t *testing.T) {
31 q := NewQueue(1, 2)
32 q.Run()
33 defer q.Terminate()
34
35 sjob := NewSyncJob("foo", func(v interface{}) (interface{}, error) {
36 return fmt.Sprintf("%s_bar", v), nil
37 })
38 q.Push(sjob)
39
40 result := <-sjob.Wait()
41 if err := sjob.Error(); err != nil {
42 t.Error(err.Error())
43 }
44
45 if !reflect.DeepEqual(result, "foo_bar") {
46 t.Error(result)
47 }
48}
49
50func ExampleQueue() {
51 q := NewQueue(1, 10)

Callers

nothing calls this directly

Calls 7

RunMethod · 0.95
TerminateMethod · 0.95
PushMethod · 0.95
NewQueueFunction · 0.85
NewSyncJobFunction · 0.85
WaitMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected