2015-01-05 10:04:29 -06:00
|
|
|
package sqlstore
|
|
|
|
|
|
|
|
import (
|
2018-01-30 08:24:14 -06:00
|
|
|
"fmt"
|
2015-01-05 10:04:29 -06:00
|
|
|
"testing"
|
2018-02-22 04:54:28 -06:00
|
|
|
"time"
|
2015-01-05 10:04:29 -06:00
|
|
|
|
2016-03-12 03:13:49 -06:00
|
|
|
"github.com/grafana/grafana/pkg/components/simplejson"
|
2015-02-05 03:37:13 -06:00
|
|
|
m "github.com/grafana/grafana/pkg/models"
|
2015-06-05 04:08:19 -05:00
|
|
|
"github.com/grafana/grafana/pkg/services/search"
|
2017-06-16 19:33:53 -05:00
|
|
|
"github.com/grafana/grafana/pkg/setting"
|
2018-01-31 10:27:28 -06:00
|
|
|
"github.com/grafana/grafana/pkg/util"
|
|
|
|
. "github.com/smartystreets/goconvey/convey"
|
2015-01-05 10:04:29 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestDashboardDataAccess(t *testing.T) {
|
|
|
|
Convey("Testing DB", t, func() {
|
2018-02-19 00:30:53 -06:00
|
|
|
InitTestDB(t)
|
2015-01-05 10:04:29 -06:00
|
|
|
|
|
|
|
Convey("Given saved dashboard", func() {
|
2017-03-27 07:36:28 -05:00
|
|
|
savedFolder := insertTestDashboard("1 test dash folder", 1, 0, true, "prod", "webapp")
|
|
|
|
savedDash := insertTestDashboard("test dash 23", 1, savedFolder.Id, false, "prod", "webapp")
|
|
|
|
insertTestDashboard("test dash 45", 1, savedFolder.Id, false, "prod")
|
|
|
|
insertTestDashboard("test dash 67", 1, 0, false, "prod", "webapp")
|
2015-01-05 10:04:29 -06:00
|
|
|
|
|
|
|
Convey("Should return dashboard model", func() {
|
|
|
|
So(savedDash.Title, ShouldEqual, "test dash 23")
|
|
|
|
So(savedDash.Slug, ShouldEqual, "test-dash-23")
|
|
|
|
So(savedDash.Id, ShouldNotEqual, 0)
|
2017-03-27 07:36:28 -05:00
|
|
|
So(savedDash.IsFolder, ShouldBeFalse)
|
2017-06-23 15:00:26 -05:00
|
|
|
So(savedDash.FolderId, ShouldBeGreaterThan, 0)
|
2018-01-29 14:23:07 -06:00
|
|
|
So(len(savedDash.Uid), ShouldBeGreaterThan, 0)
|
2017-03-27 07:36:28 -05:00
|
|
|
|
|
|
|
So(savedFolder.Title, ShouldEqual, "1 test dash folder")
|
|
|
|
So(savedFolder.Slug, ShouldEqual, "1-test-dash-folder")
|
|
|
|
So(savedFolder.Id, ShouldNotEqual, 0)
|
|
|
|
So(savedFolder.IsFolder, ShouldBeTrue)
|
2017-06-23 15:00:26 -05:00
|
|
|
So(savedFolder.FolderId, ShouldEqual, 0)
|
2018-01-29 14:23:07 -06:00
|
|
|
So(len(savedFolder.Uid), ShouldBeGreaterThan, 0)
|
2015-01-05 10:04:29 -06:00
|
|
|
})
|
|
|
|
|
2018-01-29 14:23:07 -06:00
|
|
|
Convey("Should be able to get dashboard by id", func() {
|
|
|
|
query := m.GetDashboardQuery{
|
|
|
|
Id: savedDash.Id,
|
|
|
|
OrgId: 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := GetDashboard(&query)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
So(query.Result.Title, ShouldEqual, "test dash 23")
|
|
|
|
So(query.Result.Slug, ShouldEqual, "test-dash-23")
|
|
|
|
So(query.Result.Id, ShouldEqual, savedDash.Id)
|
|
|
|
So(query.Result.Uid, ShouldEqual, savedDash.Uid)
|
|
|
|
So(query.Result.IsFolder, ShouldBeFalse)
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("Should be able to get dashboard by slug", func() {
|
2015-01-05 10:04:29 -06:00
|
|
|
query := m.GetDashboardQuery{
|
2015-02-23 13:07:49 -06:00
|
|
|
Slug: "test-dash-23",
|
|
|
|
OrgId: 1,
|
2015-01-05 10:04:29 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
err := GetDashboard(&query)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
So(query.Result.Title, ShouldEqual, "test dash 23")
|
|
|
|
So(query.Result.Slug, ShouldEqual, "test-dash-23")
|
2018-01-29 14:23:07 -06:00
|
|
|
So(query.Result.Id, ShouldEqual, savedDash.Id)
|
|
|
|
So(query.Result.Uid, ShouldEqual, savedDash.Uid)
|
|
|
|
So(query.Result.IsFolder, ShouldBeFalse)
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("Should be able to get dashboard by uid", func() {
|
|
|
|
query := m.GetDashboardQuery{
|
|
|
|
Uid: savedDash.Uid,
|
|
|
|
OrgId: 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := GetDashboard(&query)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
So(query.Result.Title, ShouldEqual, "test dash 23")
|
|
|
|
So(query.Result.Slug, ShouldEqual, "test-dash-23")
|
|
|
|
So(query.Result.Id, ShouldEqual, savedDash.Id)
|
|
|
|
So(query.Result.Uid, ShouldEqual, savedDash.Uid)
|
2017-03-27 07:36:28 -05:00
|
|
|
So(query.Result.IsFolder, ShouldBeFalse)
|
2015-01-05 10:04:29 -06:00
|
|
|
})
|
|
|
|
|
2016-04-25 01:46:15 -05:00
|
|
|
Convey("Should be able to delete dashboard", func() {
|
2017-06-17 17:24:38 -05:00
|
|
|
dash := insertTestDashboard("delete me", 1, 0, false, "delete this")
|
2016-04-25 01:46:15 -05:00
|
|
|
|
|
|
|
err := DeleteDashboard(&m.DeleteDashboardCommand{
|
2017-06-17 17:24:38 -05:00
|
|
|
Id: dash.Id,
|
2016-04-25 01:46:15 -05:00
|
|
|
OrgId: 1,
|
|
|
|
})
|
|
|
|
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
})
|
|
|
|
|
2018-01-31 10:27:28 -06:00
|
|
|
Convey("Should retry generation of uid once if it fails.", func() {
|
|
|
|
timesCalled := 0
|
|
|
|
generateNewUid = func() string {
|
|
|
|
timesCalled += 1
|
|
|
|
if timesCalled <= 2 {
|
|
|
|
return savedDash.Uid
|
|
|
|
} else {
|
|
|
|
return util.GenerateShortUid()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cmd := m.SaveDashboardCommand{
|
|
|
|
OrgId: 1,
|
|
|
|
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
|
|
|
"title": "new dash 12334",
|
|
|
|
"tags": []interface{}{},
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
|
|
|
|
err := SaveDashboard(&cmd)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
generateNewUid = util.GenerateShortUid
|
|
|
|
})
|
|
|
|
|
2018-02-22 04:54:28 -06:00
|
|
|
Convey("Should be able to create dashboard", func() {
|
|
|
|
cmd := m.SaveDashboardCommand{
|
|
|
|
OrgId: 1,
|
|
|
|
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
|
|
|
"title": "folderId",
|
|
|
|
"tags": []interface{}{},
|
|
|
|
}),
|
|
|
|
UserId: 100,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := SaveDashboard(&cmd)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(cmd.Result.CreatedBy, ShouldEqual, 100)
|
|
|
|
So(cmd.Result.Created.IsZero(), ShouldBeFalse)
|
|
|
|
So(cmd.Result.UpdatedBy, ShouldEqual, 100)
|
|
|
|
So(cmd.Result.Updated.IsZero(), ShouldBeFalse)
|
|
|
|
})
|
|
|
|
|
2018-02-08 05:48:38 -06:00
|
|
|
Convey("Should be able to update dashboard by id and remove folderId", func() {
|
2017-05-31 09:53:12 -05:00
|
|
|
cmd := m.SaveDashboardCommand{
|
|
|
|
OrgId: 1,
|
|
|
|
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
2018-02-08 05:48:38 -06:00
|
|
|
"id": savedDash.Id,
|
2017-06-23 15:00:26 -05:00
|
|
|
"title": "folderId",
|
2017-05-31 09:53:12 -05:00
|
|
|
"tags": []interface{}{},
|
|
|
|
}),
|
|
|
|
Overwrite: true,
|
2017-06-23 15:00:26 -05:00
|
|
|
FolderId: 2,
|
2018-02-22 04:54:28 -06:00
|
|
|
UserId: 100,
|
2017-05-31 09:53:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
err := SaveDashboard(&cmd)
|
|
|
|
So(err, ShouldBeNil)
|
2017-06-23 15:00:26 -05:00
|
|
|
So(cmd.Result.FolderId, ShouldEqual, 2)
|
2017-05-31 09:53:12 -05:00
|
|
|
|
|
|
|
cmd = m.SaveDashboardCommand{
|
|
|
|
OrgId: 1,
|
|
|
|
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
2018-02-08 05:48:38 -06:00
|
|
|
"id": savedDash.Id,
|
2017-06-23 15:00:26 -05:00
|
|
|
"title": "folderId",
|
2017-05-31 09:53:12 -05:00
|
|
|
"tags": []interface{}{},
|
|
|
|
}),
|
2017-06-23 15:00:26 -05:00
|
|
|
FolderId: 0,
|
2017-05-31 09:53:12 -05:00
|
|
|
Overwrite: true,
|
2018-02-22 04:54:28 -06:00
|
|
|
UserId: 100,
|
2017-05-31 09:53:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
err = SaveDashboard(&cmd)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
query := m.GetDashboardQuery{
|
2018-02-08 05:48:38 -06:00
|
|
|
Id: savedDash.Id,
|
2017-05-31 09:53:12 -05:00
|
|
|
OrgId: 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
err = GetDashboard(&query)
|
|
|
|
So(err, ShouldBeNil)
|
2017-06-23 15:00:26 -05:00
|
|
|
So(query.Result.FolderId, ShouldEqual, 0)
|
2018-02-22 04:54:28 -06:00
|
|
|
So(query.Result.CreatedBy, ShouldEqual, savedDash.CreatedBy)
|
|
|
|
So(query.Result.Created, ShouldEqual, savedDash.Created.Truncate(time.Second))
|
|
|
|
So(query.Result.UpdatedBy, ShouldEqual, 100)
|
|
|
|
So(query.Result.Updated.IsZero(), ShouldBeFalse)
|
2017-05-31 09:53:12 -05:00
|
|
|
})
|
|
|
|
|
2017-06-16 14:14:42 -05:00
|
|
|
Convey("Should be able to delete a dashboard folder and its children", func() {
|
2017-06-19 10:54:37 -05:00
|
|
|
deleteCmd := &m.DeleteDashboardCommand{Id: savedFolder.Id}
|
2017-06-16 14:14:42 -05:00
|
|
|
err := DeleteDashboard(deleteCmd)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
query := search.FindPersistedDashboardsQuery{
|
2017-06-16 19:33:53 -05:00
|
|
|
OrgId: 1,
|
2017-11-21 04:53:56 -06:00
|
|
|
FolderIds: []int64{savedFolder.Id},
|
2017-06-16 19:33:53 -05:00
|
|
|
SignedInUser: &m.SignedInUser{},
|
2017-06-16 14:14:42 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
err = SearchDashboards(&query)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
So(len(query.Result), ShouldEqual, 0)
|
|
|
|
})
|
|
|
|
|
2018-02-19 04:12:56 -06:00
|
|
|
Convey("Should return error if no dashboard is found for update when dashboard id is greater than zero", func() {
|
|
|
|
cmd := m.SaveDashboardCommand{
|
|
|
|
OrgId: 1,
|
|
|
|
Overwrite: true,
|
|
|
|
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
|
|
|
"id": float64(123412321),
|
|
|
|
"title": "Expect error",
|
|
|
|
"tags": []interface{}{},
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
|
|
|
|
err := SaveDashboard(&cmd)
|
|
|
|
So(err, ShouldEqual, m.ErrDashboardNotFound)
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("Should not return error if no dashboard is found for update when dashboard id is zero", func() {
|
|
|
|
cmd := m.SaveDashboardCommand{
|
|
|
|
OrgId: 1,
|
|
|
|
Overwrite: true,
|
|
|
|
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
|
|
|
"id": 0,
|
|
|
|
"title": "New dash",
|
|
|
|
"tags": []interface{}{},
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
|
|
|
|
err := SaveDashboard(&cmd)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
})
|
|
|
|
|
2015-01-07 05:37:24 -06:00
|
|
|
Convey("Should be able to get dashboard tags", func() {
|
2015-02-23 13:07:49 -06:00
|
|
|
query := m.GetDashboardTagsQuery{OrgId: 1}
|
2015-01-05 10:04:29 -06:00
|
|
|
|
2015-01-07 05:37:24 -06:00
|
|
|
err := GetDashboardTags(&query)
|
|
|
|
So(err, ShouldBeNil)
|
2015-01-05 10:04:29 -06:00
|
|
|
|
2015-01-20 07:15:48 -06:00
|
|
|
So(len(query.Result), ShouldEqual, 2)
|
2015-01-07 05:37:24 -06:00
|
|
|
})
|
2015-02-04 04:35:59 -06:00
|
|
|
|
2018-02-08 05:48:38 -06:00
|
|
|
Convey("Should be able to search for dashboard folder", func() {
|
|
|
|
query := search.FindPersistedDashboardsQuery{
|
|
|
|
Title: "1 test dash folder",
|
|
|
|
OrgId: 1,
|
2018-02-13 09:49:00 -06:00
|
|
|
SignedInUser: &m.SignedInUser{OrgId: 1, OrgRole: m.ROLE_EDITOR},
|
2018-02-08 05:48:38 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
err := SearchDashboards(&query)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
So(len(query.Result), ShouldEqual, 1)
|
|
|
|
hit := query.Result[0]
|
|
|
|
So(hit.Type, ShouldEqual, search.DashHitFolder)
|
|
|
|
So(hit.Url, ShouldEqual, fmt.Sprintf("/dashboards/f/%s/%s", savedFolder.Uid, savedFolder.Slug))
|
|
|
|
So(hit.FolderTitle, ShouldEqual, "")
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("Should be able to search for a dashboard folder's children", func() {
|
|
|
|
query := search.FindPersistedDashboardsQuery{
|
|
|
|
OrgId: 1,
|
|
|
|
FolderIds: []int64{savedFolder.Id},
|
2018-02-13 09:49:00 -06:00
|
|
|
SignedInUser: &m.SignedInUser{OrgId: 1, OrgRole: m.ROLE_EDITOR},
|
2018-02-08 05:48:38 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
err := SearchDashboards(&query)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
So(len(query.Result), ShouldEqual, 2)
|
|
|
|
hit := query.Result[0]
|
|
|
|
So(hit.Id, ShouldEqual, savedDash.Id)
|
|
|
|
So(hit.Url, ShouldEqual, fmt.Sprintf("/d/%s/%s", savedDash.Uid, savedDash.Slug))
|
|
|
|
So(hit.FolderId, ShouldEqual, savedFolder.Id)
|
|
|
|
So(hit.FolderUid, ShouldEqual, savedFolder.Uid)
|
|
|
|
So(hit.FolderTitle, ShouldEqual, savedFolder.Title)
|
|
|
|
So(hit.FolderUrl, ShouldEqual, fmt.Sprintf("/dashboards/f/%s/%s", savedFolder.Uid, savedFolder.Slug))
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("Should be able to search for dashboard by dashboard ids", func() {
|
|
|
|
Convey("should be able to find two dashboards by id", func() {
|
|
|
|
query := search.FindPersistedDashboardsQuery{
|
|
|
|
DashboardIds: []int64{2, 3},
|
2018-02-13 09:49:00 -06:00
|
|
|
SignedInUser: &m.SignedInUser{OrgId: 1, OrgRole: m.ROLE_EDITOR},
|
2018-02-08 05:48:38 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
err := SearchDashboards(&query)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
So(len(query.Result), ShouldEqual, 2)
|
|
|
|
|
|
|
|
hit := query.Result[0]
|
|
|
|
So(len(hit.Tags), ShouldEqual, 2)
|
|
|
|
|
|
|
|
hit2 := query.Result[1]
|
|
|
|
So(len(hit2.Tags), ShouldEqual, 1)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
|
2015-02-04 04:35:59 -06:00
|
|
|
Convey("Given two dashboards, one is starred dashboard by user 10, other starred by user 1", func() {
|
2017-03-27 07:36:28 -05:00
|
|
|
starredDash := insertTestDashboard("starred dash", 1, 0, false)
|
2015-02-04 04:35:59 -06:00
|
|
|
StarDashboard(&m.StarDashboardCommand{
|
|
|
|
DashboardId: starredDash.Id,
|
|
|
|
UserId: 10,
|
|
|
|
})
|
|
|
|
|
|
|
|
StarDashboard(&m.StarDashboardCommand{
|
|
|
|
DashboardId: savedDash.Id,
|
|
|
|
UserId: 1,
|
|
|
|
})
|
|
|
|
|
|
|
|
Convey("Should be able to search for starred dashboards", func() {
|
2018-02-13 09:49:00 -06:00
|
|
|
query := search.FindPersistedDashboardsQuery{
|
|
|
|
SignedInUser: &m.SignedInUser{UserId: 10, OrgId: 1, OrgRole: m.ROLE_EDITOR},
|
|
|
|
IsStarred: true,
|
|
|
|
}
|
2015-02-04 04:35:59 -06:00
|
|
|
err := SearchDashboards(&query)
|
|
|
|
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(query.Result), ShouldEqual, 1)
|
|
|
|
So(query.Result[0].Title, ShouldEqual, "starred dash")
|
|
|
|
})
|
|
|
|
})
|
2015-01-07 05:37:24 -06:00
|
|
|
})
|
2017-06-16 19:33:53 -05:00
|
|
|
|
2017-11-27 10:08:39 -06:00
|
|
|
Convey("Given a plugin with imported dashboards", func() {
|
|
|
|
pluginId := "test-app"
|
|
|
|
|
|
|
|
appFolder := insertTestDashboardForPlugin("app-test", 1, 0, true, pluginId)
|
|
|
|
insertTestDashboardForPlugin("app-dash1", 1, appFolder.Id, false, pluginId)
|
|
|
|
insertTestDashboardForPlugin("app-dash2", 1, appFolder.Id, false, pluginId)
|
|
|
|
|
|
|
|
Convey("Should return imported dashboard", func() {
|
|
|
|
query := m.GetDashboardsByPluginIdQuery{
|
|
|
|
PluginId: pluginId,
|
|
|
|
OrgId: 1,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := GetDashboardsByPluginId(&query)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
So(len(query.Result), ShouldEqual, 2)
|
|
|
|
})
|
|
|
|
})
|
2015-01-07 05:37:24 -06:00
|
|
|
})
|
2015-01-05 10:04:29 -06:00
|
|
|
}
|
2017-06-16 19:33:53 -05:00
|
|
|
|
2017-06-23 16:22:09 -05:00
|
|
|
func insertTestDashboard(title string, orgId int64, folderId int64, isFolder bool, tags ...interface{}) *m.Dashboard {
|
|
|
|
cmd := m.SaveDashboardCommand{
|
|
|
|
OrgId: orgId,
|
|
|
|
FolderId: folderId,
|
|
|
|
IsFolder: isFolder,
|
|
|
|
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
|
|
|
"id": nil,
|
|
|
|
"title": title,
|
|
|
|
"tags": tags,
|
|
|
|
}),
|
|
|
|
}
|
|
|
|
|
|
|
|
err := SaveDashboard(&cmd)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
2018-02-19 04:12:56 -06:00
|
|
|
cmd.Result.Data.Set("id", cmd.Result.Id)
|
|
|
|
cmd.Result.Data.Set("uid", cmd.Result.Uid)
|
|
|
|
|
2017-06-23 16:22:09 -05:00
|
|
|
return cmd.Result
|
|
|
|
}
|
|
|
|
|
2017-11-27 10:08:39 -06:00
|
|
|
func insertTestDashboardForPlugin(title string, orgId int64, folderId int64, isFolder bool, pluginId string) *m.Dashboard {
|
|
|
|
cmd := m.SaveDashboardCommand{
|
|
|
|
OrgId: orgId,
|
|
|
|
FolderId: folderId,
|
|
|
|
IsFolder: isFolder,
|
|
|
|
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
|
|
|
"id": nil,
|
|
|
|
"title": title,
|
|
|
|
}),
|
|
|
|
PluginId: pluginId,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := SaveDashboard(&cmd)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
return cmd.Result
|
|
|
|
}
|
|
|
|
|
2017-06-16 19:33:53 -05:00
|
|
|
func createUser(name string, role string, isAdmin bool) m.User {
|
|
|
|
setting.AutoAssignOrg = true
|
|
|
|
setting.AutoAssignOrgRole = role
|
|
|
|
|
|
|
|
currentUserCmd := m.CreateUserCommand{Login: name, Email: name + "@test.com", Name: "a " + name, IsAdmin: isAdmin}
|
|
|
|
err := CreateUser(¤tUserCmd)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
q1 := m.GetUserOrgListQuery{UserId: currentUserCmd.Result.Id}
|
|
|
|
GetUserOrgList(&q1)
|
|
|
|
So(q1.Result[0].Role, ShouldEqual, role)
|
|
|
|
|
|
|
|
return currentUserCmd.Result
|
|
|
|
}
|
|
|
|
|
2017-06-23 16:22:09 -05:00
|
|
|
func moveDashboard(orgId int64, dashboard *simplejson.Json, newFolderId int64) *m.Dashboard {
|
|
|
|
cmd := m.SaveDashboardCommand{
|
|
|
|
OrgId: orgId,
|
|
|
|
FolderId: newFolderId,
|
|
|
|
Dashboard: dashboard,
|
|
|
|
Overwrite: true,
|
|
|
|
}
|
|
|
|
|
|
|
|
err := SaveDashboard(&cmd)
|
|
|
|
So(err, ShouldBeNil)
|
|
|
|
|
|
|
|
return cmd.Result
|
|
|
|
}
|