dashboards_test.go 578 B

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