mirror of
https://github.com/grafana/grafana.git
synced 2024-12-02 05:29:42 -06:00
84a5910e56
* pass notification service down to the notifiers * add ns to all notifiers * remove bus from ngalert notifiers * use smaller interfaces for notificationservice * attempt to fix the tests * remove unused struct field * simplify notification service mock * trying to resolve issues in the tests * make linter happy * make linter even happier * linter, you are annoying
34 lines
923 B
Go
34 lines
923 B
Go
package notifications
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
type NotificationServiceMock struct {
|
|
Webhook models.SendWebhookSync
|
|
Email models.SendEmailCommandSync
|
|
ShouldError error
|
|
|
|
WebhookHandler func(context.Context, *models.SendWebhookSync) error
|
|
EmailHandler func(context.Context, *models.SendEmailCommandSync) error
|
|
}
|
|
|
|
func (ns *NotificationServiceMock) SendWebhookSync(ctx context.Context, cmd *models.SendWebhookSync) error {
|
|
ns.Webhook = *cmd
|
|
if ns.WebhookHandler != nil {
|
|
return ns.WebhookHandler(ctx, cmd)
|
|
}
|
|
return ns.ShouldError
|
|
}
|
|
func (ns *NotificationServiceMock) SendEmailCommandHandlerSync(ctx context.Context, cmd *models.SendEmailCommandSync) error {
|
|
ns.Email = *cmd
|
|
if ns.EmailHandler != nil {
|
|
return ns.EmailHandler(ctx, cmd)
|
|
}
|
|
return ns.ShouldError
|
|
}
|
|
|
|
func MockNotificationService() *NotificationServiceMock { return &NotificationServiceMock{} }
|