| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- package sqlstore
- import (
- "testing"
- "github.com/grafana/grafana/pkg/components/simplejson"
- "github.com/grafana/grafana/pkg/models"
- . "github.com/smartystreets/goconvey/convey"
- )
- func TestDashboardProvisioningTest(t *testing.T) {
- Convey("Testing Dashboard provisioning", t, func() {
- InitTestDB(t)
- saveDashboardCmd := &models.SaveDashboardCommand{
- OrgId: 1,
- FolderId: 0,
- IsFolder: false,
- Dashboard: simplejson.NewFromAny(map[string]interface{}{
- "id": nil,
- "title": "test dashboard",
- }),
- }
- Convey("Saving dashboards with extras", func() {
- cmd := &models.SaveProvisionedDashboardCommand{
- DashboardCmd: saveDashboardCmd,
- DashboardProvisioning: &models.DashboardProvisioning{
- Name: "default",
- ExternalId: "/var/grafana.json",
- },
- }
- err := SaveProvisionedDashboard(cmd)
- So(err, ShouldBeNil)
- So(cmd.Result, ShouldNotBeNil)
- So(cmd.Result.Id, ShouldNotEqual, 0)
- dashId := cmd.Result.Id
- Convey("Can query for provisioned dashboards", func() {
- query := &models.GetProvisionedDashboardDataQuery{Name: "default"}
- err := GetProvisionedDashboardDataQuery(query)
- So(err, ShouldBeNil)
- So(len(query.Result), ShouldEqual, 1)
- So(query.Result[0].DashboardId, ShouldEqual, dashId)
- })
- })
- })
- }
|