(t *testing.T)
| 26 | } |
| 27 | |
| 28 | func 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 | |
| 54 | func TestConsumer_Cancel_willNotBlock(t *testing.T) { |
| 55 | var ok bool |
nothing calls this directly
no test coverage detected