dashboards_test.go 634 B

12345678910111213141516171819202122232425262728293031
  1. package models
  2. import (
  3. "testing"
  4. "github.com/grafana/grafana/pkg/components/simplejson"
  5. . "github.com/smartystreets/goconvey/convey"
  6. )
  7. func TestDashboardModel(t *testing.T) {
  8. Convey("When generating slug", t, func() {
  9. dashboard := NewDashboard("Grafana Play Home")
  10. dashboard.UpdateSlug()
  11. So(dashboard.Slug, ShouldEqual, "grafana-play-home")
  12. })
  13. Convey("Given a dashboard json", t, func() {
  14. json := simplejson.New()
  15. json.Set("title", "test dash")
  16. Convey("With tags as string value", func() {
  17. json.Set("tags", "")
  18. dash := NewDashboardFromJson(json)
  19. So(len(dash.GetTags()), ShouldEqual, 0)
  20. })
  21. })
  22. }