The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/services/notifications/mock.go

42 lines
1.1 KiB

package notifications
import (
"context"
)
type NotificationServiceMock struct {
Webhook SendWebhookSync
EmailSync SendEmailCommandSync
Email SendEmailCommand
ShouldError error
WebhookHandler func(context.Context, *SendWebhookSync) error
EmailHandlerSync func(context.Context, *SendEmailCommandSync) error
EmailHandler func(context.Context, *SendEmailCommand) error
}
func (ns *NotificationServiceMock) SendWebhookSync(ctx context.Context, cmd *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 *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 *SendEmailCommand) error {
ns.Email = *cmd
if ns.EmailHandler != nil {
return ns.EmailHandler(ctx, cmd)
}
return ns.ShouldError
}
func MockNotificationService() *NotificationServiceMock { return &NotificationServiceMock{} }