grafana/pkg/models/dashboards_test.go

32 lines
634 B
Go
Raw Normal View History

package models
import (
"testing"
2016-03-11 17:13:06 -06:00
"github.com/grafana/grafana/pkg/components/simplejson"
. "github.com/smartystreets/goconvey/convey"
)
func TestDashboardModel(t *testing.T) {
Convey("When generating slug", t, func() {
dashboard := NewDashboard("Grafana Play Home")
dashboard.UpdateSlug()
So(dashboard.Slug, ShouldEqual, "grafana-play-home")
})
Convey("Given a dashboard json", t, func() {
2016-03-11 17:13:06 -06:00
json := simplejson.New()
json.Set("title", "test dash")
Convey("With tags as string value", func() {
2016-03-11 17:13:06 -06:00
json.Set("tags", "")
dash := NewDashboardFromJson(json)
So(len(dash.GetTags()), ShouldEqual, 0)
})
})
}