mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Alerting: Remove legacy alerting (#83671)
Removes legacy alerting, so long and thanks for all the fish! 🐟 --------- Co-authored-by: Matthew Jacobson <matthew.jacobson@grafana.com> Co-authored-by: Sonia Aguilar <soniaAguilarPeiron@users.noreply.github.com> Co-authored-by: Armand Grillet <armandgrillet@users.noreply.github.com> Co-authored-by: William Wernert <rwwiv@users.noreply.github.com> Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
This commit is contained in:
@@ -2,7 +2,6 @@ package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/mock"
|
||||
@@ -17,7 +16,6 @@ import (
|
||||
"github.com/grafana/grafana/pkg/services/guardian"
|
||||
"github.com/grafana/grafana/pkg/services/user"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
)
|
||||
|
||||
func TestDashboardService(t *testing.T) {
|
||||
@@ -28,11 +26,10 @@ func TestDashboardService(t *testing.T) {
|
||||
folderSvc := foldertest.NewFakeService()
|
||||
|
||||
service := &DashboardServiceImpl{
|
||||
cfg: setting.NewCfg(),
|
||||
log: log.New("test.logger"),
|
||||
dashboardStore: &fakeStore,
|
||||
folderService: folderSvc,
|
||||
dashAlertExtractor: &dummyDashAlertExtractor{},
|
||||
cfg: setting.NewCfg(),
|
||||
log: log.New("test.logger"),
|
||||
dashboardStore: &fakeStore,
|
||||
folderService: folderSvc,
|
||||
}
|
||||
|
||||
origNewDashboardGuardian := guardian.New
|
||||
@@ -80,7 +77,7 @@ func TestDashboardService(t *testing.T) {
|
||||
if tc.Error == nil {
|
||||
fakeStore.On("ValidateDashboardBeforeSave", mock.Anything, mock.Anything, mock.AnythingOfType("bool")).Return(true, nil).Once()
|
||||
}
|
||||
_, err := service.BuildSaveDashboardCommand(context.Background(), dto, true, false)
|
||||
_, err := service.BuildSaveDashboardCommand(context.Background(), dto, false)
|
||||
require.Equal(t, err, tc.Error)
|
||||
}
|
||||
})
|
||||
@@ -116,33 +113,6 @@ func TestDashboardService(t *testing.T) {
|
||||
_, err := service.SaveDashboard(context.Background(), dto, true)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("Should return validation error if alert data is invalid", func(t *testing.T) {
|
||||
origAlertingEnabledSet := service.cfg.AlertingEnabled != nil
|
||||
origAlertingEnabledVal := false
|
||||
if origAlertingEnabledSet {
|
||||
origAlertingEnabledVal = *(service.cfg.AlertingEnabled)
|
||||
}
|
||||
service.cfg.AlertingEnabled = util.Pointer(true)
|
||||
t.Cleanup(func() {
|
||||
if !origAlertingEnabledSet {
|
||||
service.cfg.AlertingEnabled = nil
|
||||
} else {
|
||||
service.cfg.AlertingEnabled = &origAlertingEnabledVal
|
||||
}
|
||||
})
|
||||
|
||||
fakeStore.On("ValidateDashboardBeforeSave", mock.Anything, mock.Anything, mock.AnythingOfType("bool")).Return(true, nil).Once()
|
||||
fakeStore.On("GetProvisionedDataByDashboardID", mock.Anything, mock.AnythingOfType("int64")).Return(nil, nil).Once()
|
||||
fakeStore.On("SaveDashboard", mock.Anything, mock.AnythingOfType("dashboards.SaveDashboardCommand")).Return(&dashboards.Dashboard{Data: simplejson.New()}, nil).Once()
|
||||
fakeStore.On("SaveAlerts", mock.Anything, mock.Anything, mock.Anything).Return(errors.New("alert validation error")).Once()
|
||||
|
||||
dto.Dashboard = dashboards.NewDashboard("Dash")
|
||||
dto.User = &user.SignedInUser{UserID: 1}
|
||||
_, err := service.SaveDashboard(context.Background(), dto, false)
|
||||
require.Error(t, err)
|
||||
require.Equal(t, err.Error(), "alert validation error")
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("Save provisioned dashboard validation", func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user