playlist_test.go 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package sqlstore
  2. import (
  3. "testing"
  4. . "github.com/smartystreets/goconvey/convey"
  5. m "github.com/grafana/grafana/pkg/models"
  6. )
  7. func TestPlaylistDataAccess(t *testing.T) {
  8. Convey("Testing Playlist data access", t, func() {
  9. InitTestDB(t)
  10. Convey("Can create playlist", func() {
  11. items := []m.PlaylistItemDTO{
  12. {Title: "graphite", Value: "graphite", Type: "dashboard_by_tag"},
  13. {Title: "Backend response times", Value: "3", Type: "dashboard_by_id"},
  14. }
  15. cmd := m.CreatePlaylistCommand{Name: "NYC office", Interval: "10m", OrgId: 1, Items: items}
  16. err := CreatePlaylist(&cmd)
  17. So(err, ShouldBeNil)
  18. Convey("can update playlist", func() {
  19. items := []m.PlaylistItemDTO{
  20. {Title: "influxdb", Value: "influxdb", Type: "dashboard_by_tag"},
  21. {Title: "Backend response times", Value: "2", Type: "dashboard_by_id"},
  22. }
  23. query := m.UpdatePlaylistCommand{Name: "NYC office ", OrgId: 1, Id: 1, Interval: "10s", Items: items}
  24. err = UpdatePlaylist(&query)
  25. So(err, ShouldBeNil)
  26. Convey("can remove playlist", func() {
  27. query := m.DeletePlaylistCommand{Id: 1}
  28. err = DeletePlaylist(&query)
  29. So(err, ShouldBeNil)
  30. })
  31. })
  32. })
  33. })
  34. }