(t *testing.T)
| 145 | } |
| 146 | |
| 147 | func TestSubscribeAsync(t *testing.T) { |
| 148 | results := make(chan int) |
| 149 | |
| 150 | bus := New() |
| 151 | bus.SubscribeAsync("/event/test", func(a int, out chan<- int) { |
| 152 | out <- a |
| 153 | }, false) |
| 154 | |
| 155 | bus.Publish("/event/test", 1, results) |
| 156 | bus.Publish("/event/test", 2, results) |
| 157 | |
| 158 | var numResults int32 |
| 159 | |
| 160 | go func() { |
| 161 | for range results { |
| 162 | atomic.AddInt32(&numResults, 1) |
| 163 | } |
| 164 | }() |
| 165 | |
| 166 | bus.WaitAsync() |
| 167 | |
| 168 | time.Sleep(10 * time.Millisecond) |
| 169 | |
| 170 | if atomic.LoadInt32(&numResults) != 2 { |
| 171 | t.Fail() |
| 172 | } |
| 173 | } |
nothing calls this directly
no test coverage detected