MCPcopy
hub / github.com/davyxu/cellnet / TestAfterTimer

Function TestAfterTimer

tests/timer_test.go:11–39  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestAfterTimer(t *testing.T) {
12
13 signal := NewSignalTester(t)
14
15 queue := cellnet.NewEventQueue()
16
17 queue.StartLoop()
18
19 timer.After(queue, 100*time.Millisecond, func() {
20 log.Debugln("after 100 ms")
21
22 signal.Done(1)
23 }, nil)
24
25 timer.After(queue, 200*time.Millisecond, func(context interface{}) {
26
27 if context.(string) != "context" {
28 t.FailNow()
29 }
30
31 log.Debugln("after 200 ms")
32
33 signal.Done(2)
34 }, "context")
35
36 signal.WaitAndExpect("100ms after not done", 1)
37
38 signal.WaitAndExpect("200ms after not done", 2)
39}
40
41func TestLoopTimer(t *testing.T) {
42

Callers

nothing calls this directly

Calls 6

StartLoopMethod · 0.95
DoneMethod · 0.95
WaitAndExpectMethod · 0.95
NewEventQueueFunction · 0.92
AfterFunction · 0.92
NewSignalTesterFunction · 0.85

Tested by

no test coverage detected