provisioning: removes id from dashboard.json

if dashboard json files contains `id` we
will just remove it form the dashboard model
before importing it into the database.

closes #11138
This commit is contained in:
bergquist
2018-03-26 13:17:39 +02:00
parent e2ba6fbb00
commit b61bc72e2a
3 changed files with 86 additions and 5 deletions
@@ -15,9 +15,10 @@ import (
)
var (
defaultDashboards string = "./test-dashboards/folder-one"
brokenDashboards string = "./test-dashboards/broken-dashboards"
oneDashboard string = "./test-dashboards/one-dashboard"
defaultDashboards = "./test-dashboards/folder-one"
brokenDashboards = "./test-dashboards/broken-dashboards"
oneDashboard = "./test-dashboards/one-dashboard"
containingId = "./test-dashboards/containing-id"
fakeService *fakeDashboardProvisioningService
)
@@ -85,6 +86,18 @@ func TestDashboardFileReader(t *testing.T) {
So(len(fakeService.inserted), ShouldEqual, 1)
})
Convey("Overrides id from dashboard.json files", func() {
cfg.Options["path"] = containingId
reader, err := NewDashboardFileReader(cfg, logger)
So(err, ShouldBeNil)
err = reader.startWalkingDisk()
So(err, ShouldBeNil)
So(len(fakeService.inserted), ShouldEqual, 1)
})
Convey("Invalid configuration should return error", func() {
cfg := &DashboardsAsConfig{
Name: "Default",