From 6db677655cc1e50e2d03ef9734e5253d59826a3e Mon Sep 17 00:00:00 2001 From: kolaente Date: Wed, 11 Aug 2021 19:08:29 +0200 Subject: [PATCH] Update docs --- docs/content/doc/development/notifications.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/docs/content/doc/development/notifications.md b/docs/content/doc/development/notifications.md index 14906f4c5..bce851e2c 100644 --- a/docs/content/doc/development/notifications.md +++ b/docs/content/doc/development/notifications.md @@ -108,6 +108,13 @@ return The `mail` package provides a `Fake()` method which you should call in the `MainTest` functions of your package. If it was called, no mails are being sent and you can instead assert they have been sent with the `AssertSent` method. +When testing, you should call the `notifications.Fake()` method in the `TestMain` function of the package you want to test. +This prevents any notifications from being sent and lets you assert a notifications has been sent like this: + +{{< highlight golang >}} +notifications.AssertSent(t, &ReminderDueNotification{}) +{{< /highlight >}} + ## Example Take a look at the [pkg/user/notifications.go](https://code.vikunja.io/api/src/branch/main/pkg/user/notifications.go) file for a good example.