feat(notifications): support delayed sending (#1142)

This commit is contained in:
nils måsén 2022-01-05 09:31:01 +01:00 committed by GitHub
parent 2fa8a2ad0c
commit 1d59fb83dd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 13 deletions

View file

@ -1,6 +1,8 @@
package notifications
import (
"time"
"github.com/containrrr/shoutrrr/pkg/types"
"github.com/containrrr/watchtower/internal/actions/mocks"
"github.com/containrrr/watchtower/internal/flags"
@ -212,7 +214,7 @@ Turns out everything is on fire
When("batching notifications", func() {
When("no messages are queued", func() {
It("should not send any notification", func() {
shoutrrr := newShoutrrrNotifier("", allButTrace, true, "", "logger://")
shoutrrr := newShoutrrrNotifier("", allButTrace, true, "", time.Duration(0), "logger://")
shoutrrr.StartNotification()
shoutrrr.SendNotification(nil)
Consistently(logBuffer).ShouldNot(gbytes.Say(`Shoutrrr:`))
@ -220,7 +222,7 @@ Turns out everything is on fire
})
When("at least one message is queued", func() {
It("should send a notification", func() {
shoutrrr := newShoutrrrNotifier("", allButTrace, true, "", "logger://")
shoutrrr := newShoutrrrNotifier("", allButTrace, true, "", time.Duration(0), "logger://")
shoutrrr.StartNotification()
logrus.Info("This log message is sponsored by ContainrrrVPN")
shoutrrr.SendNotification(nil)
@ -282,7 +284,7 @@ func sendNotificationsWithBlockingRouter(legacy bool) (*shoutrrrTypeNotifier, *b
Message: "foo bar",
}
go sendNotifications(shoutrrr)
go sendNotifications(shoutrrr, time.Duration(0))
shoutrrr.StartNotification()
_ = shoutrrr.Fire(entry)