Add docs for listener test
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
kolaente 2021-07-29 17:27:38 +02:00
parent e3825fed2d
commit 0ff8a04f2c
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 16 additions and 0 deletions

View File

@ -193,3 +193,19 @@ This prevents any events from being fired and lets you assert an event has been
{{< highlight golang >}}
events.AssertDispatched(t, &TaskCreatedEvent{})
{{< /highlight >}}
### Testing a listener
You can call an event listener manually with the `events.TestListener` method like so:
{{< highlight golang >}}
ev := &TaskCommentCreatedEvent{
Task: &task,
Doer: u,
Comment: tc,
}
events.TestListener(t, ev, &SendTaskCommentNotification{})
{{< /highlight >}}
This will call the listener's `Handle` method and assert it did not return an error when calling.