(t *testing.T)
| 76 | } |
| 77 | |
| 78 | func TestChannelReceive(t *testing.T) { |
| 79 | t.Parallel() |
| 80 | a := assertions.New(t) |
| 81 | |
| 82 | eventChan := make(events.Channel, 2) |
| 83 | eventChan.Notify(events.New(test.Context(), "evt", "event")) |
| 84 | eventChan.Notify(events.New(test.Context(), "evt", "event")) |
| 85 | eventChan.Notify(events.New(test.Context(), "overflow", "this overflows the channel")) |
| 86 | |
| 87 | runtime.Gosched() |
| 88 | |
| 89 | ctx, cancel := context.WithCancel(test.Context()) |
| 90 | |
| 91 | a.So(eventChan.ReceiveTimeout(test.Delay), should.NotBeNil) |
| 92 | a.So(eventChan.ReceiveContext(ctx), should.NotBeNil) |
| 93 | |
| 94 | cancel() |
| 95 | |
| 96 | a.So(eventChan.ReceiveTimeout(test.Delay), should.BeNil) |
| 97 | a.So(eventChan.ReceiveContext(ctx), should.BeNil) |
| 98 | } |
| 99 | |
| 100 | func ExampleContextHandler() { |
| 101 | // Usually the context comes from somewhere else (e.g. a streaming RPC): |
nothing calls this directly
no test coverage detected