dashboard_snapshot_test.go 794 B

12345678910111213141516171819202122232425262728293031323334353637
  1. package sqlstore
  2. import (
  3. "testing"
  4. . "github.com/smartystreets/goconvey/convey"
  5. m "github.com/grafana/grafana/pkg/models"
  6. )
  7. func TestDashboardSnapshotDBAccess(t *testing.T) {
  8. Convey("Testing DashboardSnapshot data access", t, func() {
  9. InitTestDB(t)
  10. Convey("Given saved snaphot", func() {
  11. cmd := m.CreateDashboardSnapshotCommand{
  12. Key: "hej",
  13. Dashboard: map[string]interface{}{
  14. "hello": "mupp",
  15. },
  16. }
  17. err := CreateDashboardSnapshot(&cmd)
  18. So(err, ShouldBeNil)
  19. Convey("Should be able to get snaphot by key", func() {
  20. query := m.GetDashboardSnapshotQuery{Key: "hej"}
  21. err = GetDashboardSnapshot(&query)
  22. So(err, ShouldBeNil)
  23. So(query.Result, ShouldNotBeNil)
  24. So(query.Result.Dashboard["hello"], ShouldEqual, "mupp")
  25. })
  26. })
  27. })
  28. }