dashboard_snapshot_test.go 890 B

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