Chore: Remove bus from ngalert (#44465)

* 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
This commit is contained in:
Serge Zaitsev
2022-01-26 16:42:40 +01:00
committed by GitHub
parent ad4a9a48d2
commit 84a5910e56
48 changed files with 374 additions and 374 deletions
+9 -5
View File
@@ -1,12 +1,16 @@
package server
import "github.com/grafana/grafana/pkg/services/sqlstore"
import (
"github.com/grafana/grafana/pkg/services/notifications"
"github.com/grafana/grafana/pkg/services/sqlstore"
)
func ProvideTestEnv(server *Server, store *sqlstore.SQLStore) (*TestEnv, error) {
return &TestEnv{server, store}, nil
func ProvideTestEnv(server *Server, store *sqlstore.SQLStore, ns *notifications.NotificationServiceMock) (*TestEnv, error) {
return &TestEnv{server, store, ns}, nil
}
type TestEnv struct {
Server *Server
SQLStore *sqlstore.SQLStore
Server *Server
SQLStore *sqlstore.SQLStore
NotificationService *notifications.NotificationServiceMock
}
+8
View File
@@ -190,6 +190,9 @@ var wireSet = wire.NewSet(
wireBasicSet,
sqlstore.ProvideService,
ngmetrics.ProvideService,
wire.Bind(new(notifications.Service), new(*notifications.NotificationService)),
wire.Bind(new(notifications.WebhookSender), new(*notifications.NotificationService)),
wire.Bind(new(notifications.EmailSender), new(*notifications.NotificationService)),
)
var wireTestSet = wire.NewSet(
@@ -197,6 +200,11 @@ var wireTestSet = wire.NewSet(
ProvideTestEnv,
sqlstore.ProvideServiceForTests,
ngmetrics.ProvideServiceForTest,
notifications.MockNotificationService,
wire.Bind(new(notifications.Service), new(*notifications.NotificationServiceMock)),
wire.Bind(new(notifications.WebhookSender), new(*notifications.NotificationServiceMock)),
wire.Bind(new(notifications.EmailSender), new(*notifications.NotificationServiceMock)),
)
func Initialize(cla setting.CommandLineArgs, opts Options, apiOpts api.ServerOptions) (*Server, error) {