Fix for validating tags in dashboard json in backend, Fixes #2152

This commit is contained in:
Torkel Ödegaard 2015-06-12 09:04:10 +02:00
parent 7ce31bfaa0
commit bae1e2f0c1
2 changed files with 14 additions and 1 deletions

View File

@ -49,7 +49,7 @@ func NewDashboard(title string) *Dashboard {
// GetTags turns the tags in data json into go string array
func (dash *Dashboard) GetTags() []string {
jsonTags := dash.Data["tags"]
if jsonTags == nil {
if jsonTags == nil || jsonTags == "" {
return []string{}
}

View File

@ -15,4 +15,17 @@ func TestDashboardModel(t *testing.T) {
So(dashboard.Slug, ShouldEqual, "grafana-play-home")
})
Convey("Given a dashboard json", t, func() {
json := map[string]interface{}{
"title": "test dash",
}
Convey("With tags as string value", func() {
json["tags"] = ""
dash := NewDashboardFromJson(json)
So(len(dash.GetTags()), ShouldEqual, 0)
})
})
}