Linting fixes for dashboard provsioning (#23576)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package dashboards
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
"math/rand"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -9,6 +8,8 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
"github.com/grafana/grafana/pkg/models"
|
||||
"github.com/grafana/grafana/pkg/services/dashboards"
|
||||
@@ -21,7 +22,7 @@ var (
|
||||
defaultDashboards = "testdata/test-dashboards/folder-one"
|
||||
brokenDashboards = "testdata/test-dashboards/broken-dashboards"
|
||||
oneDashboard = "testdata/test-dashboards/one-dashboard"
|
||||
containingId = "testdata/test-dashboards/containing-id"
|
||||
containingID = "testdata/test-dashboards/containing-id"
|
||||
unprovision = "testdata/test-dashboards/unprovision"
|
||||
|
||||
fakeService *fakeDashboardProvisioningService
|
||||
@@ -140,7 +141,7 @@ func TestDashboardFileReader(t *testing.T) {
|
||||
})
|
||||
|
||||
Convey("Overrides id from dashboard.json files", func() {
|
||||
cfg.Options["path"] = containingId
|
||||
cfg.Options["path"] = containingID
|
||||
|
||||
reader, err := NewDashboardFileReader(cfg, logger)
|
||||
So(err, ShouldBeNil)
|
||||
@@ -171,8 +172,8 @@ func TestDashboardFileReader(t *testing.T) {
|
||||
})
|
||||
|
||||
Convey("Two dashboard providers should be able to provisioned the same dashboard without uid", func() {
|
||||
cfg1 := &DashboardsAsConfig{Name: "1", Type: "file", OrgId: 1, Folder: "f1", Options: map[string]interface{}{"path": containingId}}
|
||||
cfg2 := &DashboardsAsConfig{Name: "2", Type: "file", OrgId: 1, Folder: "f2", Options: map[string]interface{}{"path": containingId}}
|
||||
cfg1 := &DashboardsAsConfig{Name: "1", Type: "file", OrgId: 1, Folder: "f1", Options: map[string]interface{}{"path": containingID}}
|
||||
cfg2 := &DashboardsAsConfig{Name: "2", Type: "file", OrgId: 1, Folder: "f2", Options: map[string]interface{}{"path": containingID}}
|
||||
|
||||
reader1, err := NewDashboardFileReader(cfg1, logger)
|
||||
So(err, ShouldBeNil)
|
||||
@@ -212,7 +213,7 @@ func TestDashboardFileReader(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
_, err := getOrCreateFolderId(cfg, fakeService)
|
||||
_, err := getOrCreateFolderID(cfg, fakeService)
|
||||
So(err, ShouldEqual, ErrFolderNameMissing)
|
||||
})
|
||||
|
||||
@@ -227,11 +228,11 @@ func TestDashboardFileReader(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
folderId, err := getOrCreateFolderId(cfg, fakeService)
|
||||
folderID, err := getOrCreateFolderID(cfg, fakeService)
|
||||
So(err, ShouldBeNil)
|
||||
inserted := false
|
||||
for _, d := range fakeService.inserted {
|
||||
if d.Dashboard.IsFolder && d.Dashboard.Id == folderId {
|
||||
if d.Dashboard.IsFolder && d.Dashboard.Id == folderID {
|
||||
inserted = true
|
||||
}
|
||||
}
|
||||
@@ -410,10 +411,10 @@ func (s *fakeDashboardProvisioningService) SaveFolderForProvisionedDashboards(dt
|
||||
return dto.Dashboard, nil
|
||||
}
|
||||
|
||||
func (s *fakeDashboardProvisioningService) UnprovisionDashboard(dashboardId int64) error {
|
||||
func (s *fakeDashboardProvisioningService) UnprovisionDashboard(dashboardID int64) error {
|
||||
for key, val := range s.provisioned {
|
||||
for index, dashboard := range val {
|
||||
if dashboard.DashboardId == dashboardId {
|
||||
if dashboard.DashboardId == dashboardID {
|
||||
s.provisioned[key] = append(s.provisioned[key][:index], s.provisioned[key][index+1:]...)
|
||||
}
|
||||
}
|
||||
@@ -421,21 +422,21 @@ func (s *fakeDashboardProvisioningService) UnprovisionDashboard(dashboardId int6
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *fakeDashboardProvisioningService) DeleteProvisionedDashboard(dashboardId int64, orgId int64) error {
|
||||
err := s.UnprovisionDashboard(dashboardId)
|
||||
func (s *fakeDashboardProvisioningService) DeleteProvisionedDashboard(dashboardID int64, orgID int64) error {
|
||||
err := s.UnprovisionDashboard(dashboardID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for index, val := range s.inserted {
|
||||
if val.Dashboard.Id == dashboardId {
|
||||
if val.Dashboard.Id == dashboardID {
|
||||
s.inserted = append(s.inserted[:index], s.inserted[util.MinInt(index+1, len(s.inserted)):]...)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *fakeDashboardProvisioningService) GetProvisionedDashboardDataByDashboardId(dashboardId int64) (*models.DashboardProvisioning, error) {
|
||||
func (s *fakeDashboardProvisioningService) GetProvisionedDashboardDataByDashboardId(dashboardID int64) (*models.DashboardProvisioning, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user