Chore: Remove bus from the alerting service (#44496)
* propagate notificationservice down to the notifiers * replace dispatch in result handler * remove dispatch from the rule reader * remove dispatch from eval context * remove dispatch from alerting usage * remove dispatch from alerting usage * remove dispatch from notifier * attempt to fix tests in alerting * hello linter, my old friend; also disable some tests for now * use mocks to fix the tests * resolving wire providers * make linter happy * remove yet another bus.dispatch * fix tests using store mock
This commit is contained in:
@@ -139,7 +139,7 @@ func TestNotificationAsConfig(t *testing.T) {
|
||||
t.Run("One configured notification", func(t *testing.T) {
|
||||
t.Run("no notification in database", func(t *testing.T) {
|
||||
setup()
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), logger)
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), nil, logger)
|
||||
|
||||
err := dc.applyChanges(context.Background(), twoNotificationsConfig)
|
||||
if err != nil {
|
||||
@@ -170,7 +170,7 @@ func TestNotificationAsConfig(t *testing.T) {
|
||||
require.Equal(t, len(notificationsQuery.Result), 1)
|
||||
|
||||
t.Run("should update one notification", func(t *testing.T) {
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), logger)
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), nil, logger)
|
||||
err = dc.applyChanges(context.Background(), twoNotificationsConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("applyChanges return an error %v", err)
|
||||
@@ -194,7 +194,7 @@ func TestNotificationAsConfig(t *testing.T) {
|
||||
})
|
||||
t.Run("Two notifications with is_default", func(t *testing.T) {
|
||||
setup()
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), logger)
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), nil, logger)
|
||||
err := dc.applyChanges(context.Background(), doubleNotificationsConfig)
|
||||
t.Run("should both be inserted", func(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
@@ -237,7 +237,7 @@ func TestNotificationAsConfig(t *testing.T) {
|
||||
require.Equal(t, len(notificationsQuery.Result), 2)
|
||||
|
||||
t.Run("should have two new notifications", func(t *testing.T) {
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), logger)
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), nil, logger)
|
||||
err := dc.applyChanges(context.Background(), twoNotificationsConfig)
|
||||
if err != nil {
|
||||
t.Fatalf("applyChanges return an error %v", err)
|
||||
@@ -271,7 +271,7 @@ func TestNotificationAsConfig(t *testing.T) {
|
||||
err = sqlStore.CreateAlertNotificationCommand(context.Background(), &existingNotificationCmd)
|
||||
require.NoError(t, err)
|
||||
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), logger)
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), nil, logger)
|
||||
err = dc.applyChanges(context.Background(), correctPropertiesWithOrgName)
|
||||
if err != nil {
|
||||
t.Fatalf("applyChanges return an error %v", err)
|
||||
@@ -290,7 +290,7 @@ func TestNotificationAsConfig(t *testing.T) {
|
||||
|
||||
t.Run("Config doesn't contain required field", func(t *testing.T) {
|
||||
setup()
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), logger)
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), nil, logger)
|
||||
err := dc.applyChanges(context.Background(), noRequiredFields)
|
||||
require.NotNil(t, err)
|
||||
|
||||
@@ -304,7 +304,7 @@ func TestNotificationAsConfig(t *testing.T) {
|
||||
t.Run("Empty yaml file", func(t *testing.T) {
|
||||
t.Run("should have not changed repo", func(t *testing.T) {
|
||||
setup()
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), logger)
|
||||
dc := newNotificationProvisioner(ossencryption.ProvideService(), nil, logger)
|
||||
err := dc.applyChanges(context.Background(), emptyFile)
|
||||
if err != nil {
|
||||
t.Fatalf("applyChanges return an error %v", err)
|
||||
|
||||
Reference in New Issue
Block a user