MCPcopy Create free account
hub / github.com/assembla/cony / TestConsumer_Cancel

Function TestConsumer_Cancel

consumer_test.go:28–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26}
27
28func TestConsumer_Cancel(t *testing.T) {
29 var stopped bool
30 done := make(chan bool)
31
32 c := newTestConsumer()
33
34 go func() {
35 <-done
36 select {
37 case <-c.stop:
38 stopped = true
39 case <-time.After(1 * time.Millisecond):
40 return
41 }
42 done <- true
43 }()
44
45 done <- true
46 c.Cancel()
47 <-done
48
49 if !stopped {
50 t.Error("Cancel() should send stop signal")
51 }
52}
53
54func TestConsumer_Cancel_willNotBlock(t *testing.T) {
55 var ok bool

Callers

nothing calls this directly

Calls 2

newTestConsumerFunction · 0.85
CancelMethod · 0.45

Tested by

no test coverage detected