dashboard_provisioning_test.go 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package sqlstore
  2. import (
  3. "testing"
  4. "github.com/grafana/grafana/pkg/components/simplejson"
  5. "github.com/grafana/grafana/pkg/models"
  6. . "github.com/smartystreets/goconvey/convey"
  7. )
  8. func TestDashboardProvisioningTest(t *testing.T) {
  9. Convey("Testing Dashboard provisioning", t, func() {
  10. InitTestDB(t)
  11. saveDashboardCmd := &models.SaveDashboardCommand{
  12. OrgId: 1,
  13. FolderId: 0,
  14. IsFolder: false,
  15. Dashboard: simplejson.NewFromAny(map[string]interface{}{
  16. "id": nil,
  17. "title": "test dashboard",
  18. }),
  19. }
  20. Convey("Saving dashboards with extras", func() {
  21. cmd := &models.SaveProvisionedDashboardCommand{
  22. DashboardCmd: saveDashboardCmd,
  23. DashboardProvisioning: &models.DashboardProvisioning{
  24. Name: "default",
  25. ExternalId: "/var/grafana.json",
  26. },
  27. }
  28. err := SaveProvisionedDashboard(cmd)
  29. So(err, ShouldBeNil)
  30. So(cmd.Result, ShouldNotBeNil)
  31. So(cmd.Result.Id, ShouldNotEqual, 0)
  32. Convey("Can query for provisioned dashboards", func() {
  33. query := &models.GetProvisionedDashboardDataQuery{Name: "default"}
  34. err := GetProvisionedDashboardDataQuery(query)
  35. So(err, ShouldBeNil)
  36. So(len(query.Result), ShouldEqual, 1)
  37. })
  38. })
  39. })
  40. }