From c4a18030605a0822fa1a703c29492fb288d5bb7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 19 Jun 2017 17:30:54 -0400 Subject: [PATCH] refactoring more renaming --- pkg/api/dashboard_acl.go | 2 +- pkg/api/dashboard_acl_test.go | 2 +- pkg/models/dashboard_acl.go | 2 +- pkg/services/sqlstore/dashboard_acl.go | 4 ++-- pkg/services/sqlstore/dashboard_acl_test.go | 24 ++++++++++----------- pkg/services/sqlstore/org_test.go | 8 +++---- pkg/services/sqlstore/user_group_test.go | 4 ++-- pkg/services/sqlstore/user_test.go | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/pkg/api/dashboard_acl.go b/pkg/api/dashboard_acl.go index e19cb51f56f..0fdac00250c 100644 --- a/pkg/api/dashboard_acl.go +++ b/pkg/api/dashboard_acl.go @@ -18,7 +18,7 @@ func GetDashboardAcl(c *middleware.Context) Response { return dashboardGuardianResponse(err) } - query := m.GetDashboardPermissionsQuery{DashboardId: dashId} + query := m.GetDashboardAclInfoListQuery{DashboardId: dashId} if err := bus.Dispatch(&query); err != nil { return ApiError(500, "Failed to get Dashboard ACL", err) } diff --git a/pkg/api/dashboard_acl_test.go b/pkg/api/dashboard_acl_test.go index c108bd717de..e482ffd2aca 100644 --- a/pkg/api/dashboard_acl_test.go +++ b/pkg/api/dashboard_acl_test.go @@ -25,7 +25,7 @@ func TestDashboardAclApiEndpoint(t *testing.T) { {Id: 4, OrgId: 1, DashboardId: 1, UserGroupId: 2, Permissions: models.PERMISSION_READ_ONLY_EDIT}, } - bus.AddHandler("test", func(query *models.GetDashboardPermissionsQuery) error { + bus.AddHandler("test", func(query *models.GetDashboardAclInfoListQuery) error { query.Result = dtoRes return nil }) diff --git a/pkg/models/dashboard_acl.go b/pkg/models/dashboard_acl.go index eb5ecf2c4e2..cff9c476d9d 100644 --- a/pkg/models/dashboard_acl.go +++ b/pkg/models/dashboard_acl.go @@ -83,7 +83,7 @@ type RemoveDashboardAclCommand struct { // // QUERIES // -type GetDashboardPermissionsQuery struct { +type GetDashboardAclInfoListQuery struct { DashboardId int64 Result []*DashboardAclInfoDTO } diff --git a/pkg/services/sqlstore/dashboard_acl.go b/pkg/services/sqlstore/dashboard_acl.go index 1fe20cf609b..95bfa6738a6 100644 --- a/pkg/services/sqlstore/dashboard_acl.go +++ b/pkg/services/sqlstore/dashboard_acl.go @@ -10,7 +10,7 @@ import ( func init() { bus.AddHandler("sql", SetDashboardAcl) bus.AddHandler("sql", RemoveDashboardAcl) - bus.AddHandler("sql", GetDashboardPermissions) + bus.AddHandler("sql", GetDashboardAclInfoList) bus.AddHandler("sql", GetInheritedDashboardAcl) } @@ -107,7 +107,7 @@ func GetInheritedDashboardAcl(query *m.GetInheritedDashboardAclQuery) error { return x.SQL(rawSQL, query.DashboardId, query.DashboardId, query.OrgId).Find(&query.Result) } -func GetDashboardPermissions(query *m.GetDashboardPermissionsQuery) error { +func GetDashboardAclInfoList(query *m.GetDashboardAclInfoListQuery) error { rawSQL := `SELECT da.id, da.org_id, diff --git a/pkg/services/sqlstore/dashboard_acl_test.go b/pkg/services/sqlstore/dashboard_acl_test.go index 634ae946c24..b98127410e5 100644 --- a/pkg/services/sqlstore/dashboard_acl_test.go +++ b/pkg/services/sqlstore/dashboard_acl_test.go @@ -75,8 +75,8 @@ func TestDashboardAclDataAccess(t *testing.T) { }) So(err, ShouldBeNil) - q1 := &m.GetDashboardPermissionsQuery{DashboardId: savedFolder.Id} - err = GetDashboardPermissions(q1) + q1 := &m.GetDashboardAclInfoListQuery{DashboardId: savedFolder.Id} + err = GetDashboardAclInfoList(q1) So(err, ShouldBeNil) So(q1.Result[0].DashboardId, ShouldEqual, savedFolder.Id) So(q1.Result[0].Permissions, ShouldEqual, m.PERMISSION_EDIT) @@ -102,8 +102,8 @@ func TestDashboardAclDataAccess(t *testing.T) { }) So(err, ShouldBeNil) - q3 := &m.GetDashboardPermissionsQuery{DashboardId: savedFolder.Id} - err = GetDashboardPermissions(q3) + q3 := &m.GetDashboardAclInfoListQuery{DashboardId: savedFolder.Id} + err = GetDashboardAclInfoList(q3) So(err, ShouldBeNil) So(len(q3.Result), ShouldEqual, 1) So(q3.Result[0].DashboardId, ShouldEqual, savedFolder.Id) @@ -120,8 +120,8 @@ func TestDashboardAclDataAccess(t *testing.T) { }) So(err, ShouldBeNil) - q3 := &m.GetDashboardPermissionsQuery{DashboardId: savedFolder.Id} - err = GetDashboardPermissions(q3) + q3 := &m.GetDashboardAclInfoListQuery{DashboardId: savedFolder.Id} + err = GetDashboardAclInfoList(q3) So(err, ShouldBeNil) So(len(q3.Result), ShouldEqual, 0) }) @@ -141,8 +141,8 @@ func TestDashboardAclDataAccess(t *testing.T) { }) So(err, ShouldBeNil) - q1 := &m.GetDashboardPermissionsQuery{DashboardId: savedFolder.Id} - err = GetDashboardPermissions(q1) + q1 := &m.GetDashboardAclInfoListQuery{DashboardId: savedFolder.Id} + err = GetDashboardAclInfoList(q1) So(err, ShouldBeNil) So(q1.Result[0].DashboardId, ShouldEqual, savedFolder.Id) So(q1.Result[0].Permissions, ShouldEqual, m.PERMISSION_EDIT) @@ -158,8 +158,8 @@ func TestDashboardAclDataAccess(t *testing.T) { }) So(err, ShouldBeNil) - q3 := &m.GetDashboardPermissionsQuery{DashboardId: savedFolder.Id} - err = GetDashboardPermissions(q3) + q3 := &m.GetDashboardAclInfoListQuery{DashboardId: savedFolder.Id} + err = GetDashboardAclInfoList(q3) So(err, ShouldBeNil) So(len(q3.Result), ShouldEqual, 1) So(q3.Result[0].DashboardId, ShouldEqual, savedFolder.Id) @@ -176,8 +176,8 @@ func TestDashboardAclDataAccess(t *testing.T) { }) So(err, ShouldBeNil) - q3 := &m.GetDashboardPermissionsQuery{DashboardId: savedFolder.Id} - err = GetDashboardPermissions(q3) + q3 := &m.GetDashboardAclInfoListQuery{DashboardId: savedFolder.Id} + err = GetDashboardAclInfoList(q3) So(err, ShouldBeNil) So(len(q3.Result), ShouldEqual, 0) }) diff --git a/pkg/services/sqlstore/org_test.go b/pkg/services/sqlstore/org_test.go index abff3d2e77c..7af80f38320 100644 --- a/pkg/services/sqlstore/org_test.go +++ b/pkg/services/sqlstore/org_test.go @@ -186,16 +186,16 @@ func TestAccountDataAccess(t *testing.T) { So(err, ShouldBeNil) Convey("Should remove dependent permissions for deleted org user", func() { - permQuery := &m.GetDashboardPermissionsQuery{DashboardId: 1} - err = GetDashboardPermissions(permQuery) + permQuery := &m.GetDashboardAclInfoListQuery{DashboardId: 1} + err = GetDashboardAclInfoList(permQuery) So(err, ShouldBeNil) So(len(permQuery.Result), ShouldEqual, 0) }) Convey("Should not remove dashboard permissions for same user in another org", func() { - permQuery := &m.GetDashboardPermissionsQuery{DashboardId: 2} - err = GetDashboardPermissions(permQuery) + permQuery := &m.GetDashboardAclInfoListQuery{DashboardId: 2} + err = GetDashboardAclInfoList(permQuery) So(err, ShouldBeNil) So(permQuery.Result[0].OrgId, ShouldEqual, ac3.OrgId) diff --git a/pkg/services/sqlstore/user_group_test.go b/pkg/services/sqlstore/user_group_test.go index 4121fc462d4..34e4f5e5bbf 100644 --- a/pkg/services/sqlstore/user_group_test.go +++ b/pkg/services/sqlstore/user_group_test.go @@ -103,8 +103,8 @@ func TestUserGroupCommandsAndQueries(t *testing.T) { err = GetUserGroupById(query) So(err, ShouldEqual, m.ErrUserGroupNotFound) - permQuery := &m.GetDashboardPermissionsQuery{DashboardId: 1} - err = GetDashboardPermissions(permQuery) + permQuery := &m.GetDashboardAclInfoListQuery{DashboardId: 1} + err = GetDashboardAclInfoList(permQuery) So(err, ShouldBeNil) So(len(permQuery.Result), ShouldEqual, 0) diff --git a/pkg/services/sqlstore/user_test.go b/pkg/services/sqlstore/user_test.go index 898db77e4e2..33ecea6da9a 100644 --- a/pkg/services/sqlstore/user_test.go +++ b/pkg/services/sqlstore/user_test.go @@ -116,8 +116,8 @@ func TestUserDataAccess(t *testing.T) { So(len(query.Result), ShouldEqual, 1) - permQuery := &m.GetDashboardPermissionsQuery{DashboardId: 1} - err = GetDashboardPermissions(permQuery) + permQuery := &m.GetDashboardAclInfoListQuery{DashboardId: 1} + err = GetDashboardAclInfoList(permQuery) So(err, ShouldBeNil) So(len(permQuery.Result), ShouldEqual, 0)