mirror of
https://github.com/grafana/grafana.git
synced 2024-12-02 05:29:42 -06:00
12420260ef
* Remove bus from org invite api * Fix lint * Remove comment
45 lines
1.2 KiB
Go
45 lines
1.2 KiB
Go
package notifications
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
type NotificationServiceMock struct {
|
|
Webhook models.SendWebhookSync
|
|
EmailSync models.SendEmailCommandSync
|
|
Email models.SendEmailCommand
|
|
ShouldError error
|
|
|
|
WebhookHandler func(context.Context, *models.SendWebhookSync) error
|
|
EmailHandlerSync func(context.Context, *models.SendEmailCommandSync) error
|
|
EmailHandler func(context.Context, *models.SendEmailCommand) 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.EmailSync = *cmd
|
|
if ns.EmailHandlerSync != nil {
|
|
return ns.EmailHandlerSync(ctx, cmd)
|
|
}
|
|
return ns.ShouldError
|
|
}
|
|
|
|
func (ns *NotificationServiceMock) SendEmailCommandHandler(ctx context.Context, cmd *models.SendEmailCommand) error {
|
|
ns.Email = *cmd
|
|
if ns.EmailHandler != nil {
|
|
return ns.EmailHandler(ctx, cmd)
|
|
}
|
|
return ns.ShouldError
|
|
}
|
|
|
|
func MockNotificationService() *NotificationServiceMock { return &NotificationServiceMock{} }
|