feat(plugins): dashboard import for data sources is working! #4298

This commit is contained in:
Torkel Ödegaard
2016-03-12 10:13:49 +01:00
parent 3fb0b71822
commit 0398face05
18 changed files with 278 additions and 80 deletions
+10 -5
View File
@@ -1,6 +1,7 @@
package plugins
import (
"io/ioutil"
"testing"
"github.com/grafana/grafana/pkg/bus"
@@ -34,7 +35,7 @@ func TestDashboardImport(t *testing.T) {
OrgId: 1,
UserId: 1,
Inputs: []ImportDashboardInput{
{Name: "*", Type: "datasource"},
{Name: "*", Type: "datasource", Value: "graphite"},
},
}
@@ -44,11 +45,15 @@ func TestDashboardImport(t *testing.T) {
Convey("should install dashboard", func() {
So(importedDash, ShouldNotBeNil)
dashStr, _ := importedDash.Data.EncodePretty()
So(string(dashStr), ShouldEqual, "")
resultStr, _ := importedDash.Data.EncodePretty()
expectedBytes, _ := ioutil.ReadFile("../../tests/test-app/dashboards/connections_result.json")
expectedJson, _ := simplejson.NewJson(expectedBytes)
expectedStr, _ := expectedJson.EncodePretty()
// So(panel["datasource"], ShouldEqual, "graphite")
// So(importedDash.Data["__inputs"], ShouldBeNil)
So(string(resultStr), ShouldEqual, string(expectedStr))
panel := importedDash.Data.Get("rows").GetIndex(0).Get("panels").GetIndex(0)
So(panel.Get("datasource").MustString(), ShouldEqual, "graphite")
})
})