mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix for validating tags in dashboard json in backend, Fixes #2152
This commit is contained in:
parent
7ce31bfaa0
commit
bae1e2f0c1
@ -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{}
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user