mirror of
https://github.com/grafana/grafana.git
synced 2025-09-27 12:44:15 +08:00
test(playlist): add test for playlist sqlstoretest(playlist): add test for playlist sqlstoretest(playlist): add test for playlist sqlstoretest(playlist): add test for playlist sqlstoretest(playlist): add test for playlist sqlstoretest(playlist): add test for playlist sqlstoretest(playlist): add test for playlist sqlstoretest(playlist): add test for playlist sqlstoretest(playlist): add test for playlist sqlstore
This commit is contained in:
73
pkg/services/sqlstore/playlist_test.go
Normal file
73
pkg/services/sqlstore/playlist_test.go
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
package sqlstore
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
. "github.com/smartystreets/goconvey/convey"
|
||||||
|
|
||||||
|
m "github.com/grafana/grafana/pkg/models"
|
||||||
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
|
type UpdatePlaylistCommand struct {
|
||||||
|
OrgId int64 `json:"-"`
|
||||||
|
Id int64 `json:"id" binding:"Required"`
|
||||||
|
Name string `json:"name" binding:"Required"`
|
||||||
|
Type string `json:"type"`
|
||||||
|
Interval string `json:"interval"`
|
||||||
|
Items []PlaylistItemDTO `json:"items"`
|
||||||
|
|
||||||
|
Result *PlaylistDTO
|
||||||
|
}
|
||||||
|
|
||||||
|
type CreatePlaylistCommand struct {
|
||||||
|
Name string `json:"name" binding:"Required"`
|
||||||
|
Interval string `json:"interval"`
|
||||||
|
Data []int64 `json:"data"`
|
||||||
|
Items []PlaylistItemDTO `json:"items"`
|
||||||
|
|
||||||
|
OrgId int64 `json:"-"`
|
||||||
|
Result *Playlist
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeletePlaylistCommand struct {
|
||||||
|
Id int64
|
||||||
|
OrgId int64
|
||||||
|
}
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
func TestPlaylistDataAccess(t *testing.T) {
|
||||||
|
|
||||||
|
Convey("Testing Playlist data access", t, func() {
|
||||||
|
InitTestDB(t)
|
||||||
|
|
||||||
|
Convey("Can create playlist", func() {
|
||||||
|
items := []m.PlaylistItemDTO{
|
||||||
|
m.PlaylistItemDTO{Title: "graphite", Value: "graphite", Type: "dashboard_by_tag"},
|
||||||
|
m.PlaylistItemDTO{Title: "Backend response times", Value: "3", Type: "dashboard_by_id"},
|
||||||
|
}
|
||||||
|
cmd := m.CreatePlaylistCommand{Name: "NYC office", Interval: "10m", OrgId: 1, Items: items}
|
||||||
|
err := CreatePlaylist(&cmd)
|
||||||
|
So(err, ShouldBeNil)
|
||||||
|
|
||||||
|
Convey("can update playlist", func() {
|
||||||
|
items := []m.PlaylistItemDTO{
|
||||||
|
m.PlaylistItemDTO{Title: "influxdb", Value: "influxdb", Type: "dashboard_by_tag"},
|
||||||
|
m.PlaylistItemDTO{Title: "Backend response times", Value: "2", Type: "dashboard_by_id"},
|
||||||
|
}
|
||||||
|
query := m.UpdatePlaylistCommand{Name: "NYC office ", OrgId: 1, Id: 1, Interval: "10s", Items: items}
|
||||||
|
err = UpdatePlaylist(&query)
|
||||||
|
|
||||||
|
So(err, ShouldBeNil)
|
||||||
|
|
||||||
|
Convey("can remove playlist", func() {
|
||||||
|
query := m.DeletePlaylistCommand{Id: 1}
|
||||||
|
err = DeletePlaylist(&query)
|
||||||
|
|
||||||
|
So(err, ShouldBeNil)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
Reference in New Issue
Block a user