CollectEvents collects events published by f.
(f func())
| 243 | |
| 244 | // CollectEvents collects events published by f. |
| 245 | func CollectEvents(f func()) []events.Event { |
| 246 | var evs []events.Event |
| 247 | defer SetDefaultEventsPubSub(&MockEventPubSub{ |
| 248 | PublishFunc: func(evts ...events.Event) { evs = append(evs, evts...) }, |
| 249 | })() |
| 250 | f() |
| 251 | return evs |
| 252 | } |
| 253 | |
| 254 | // RedirectEvents redirects the published events to the |
| 255 | // provided channel until the returned function is called. |