provisioning: simplify db query

the GetProvisionedDashboardQuery wasent used for anything
else than check if a dashboard is provisioned or not. So
we simplified this query to make it more maintainable.
This commit is contained in:
bergquist
2018-04-10 12:30:37 +02:00
parent 0f9b592428
commit 949484b949
8 changed files with 41 additions and 53 deletions

View File

@@ -56,8 +56,9 @@ func TestDashboardService(t *testing.T) {
return nil
})
bus.AddHandler("test", func(cmd *models.GetProvisionedDashboardByDashboardId) error {
return models.ErrDashboardProvisioningDoesNotExist
bus.AddHandler("test", func(cmd *models.IsDashboardProvisionedQuery) error {
cmd.Result = false
return nil
})
testCases := []struct {
@@ -84,8 +85,8 @@ func TestDashboardService(t *testing.T) {
})
Convey("Should return validation error if dashboard is provisioned", func() {
bus.AddHandler("test", func(cmd *models.GetProvisionedDashboardByDashboardId) error {
cmd.Result = &models.DashboardProvisioning{}
bus.AddHandler("test", func(cmd *models.IsDashboardProvisionedQuery) error {
cmd.Result = true
return nil
})
@@ -105,8 +106,9 @@ func TestDashboardService(t *testing.T) {
})
Convey("Should return validation error if alert data is invalid", func() {
bus.AddHandler("test", func(cmd *models.GetProvisionedDashboardByDashboardId) error {
return models.ErrDashboardProvisioningDoesNotExist
bus.AddHandler("test", func(cmd *models.IsDashboardProvisionedQuery) error {
cmd.Result = false
return nil
})
bus.AddHandler("test", func(cmd *models.ValidateDashboardAlertsCommand) error {