Chore: Deprecate ID from Folder (#78281)
* Chore: Deprecate ID from Folder * chore: add more linter comments * chore: add missing lint comment
This commit is contained in:
@@ -415,6 +415,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
// nolint:staticcheck
|
||||
dashboardService.On("SaveDashboard", mock.Anything, mock.AnythingOfType("*dashboards.SaveDashboardDTO"), mock.AnythingOfType("bool")).
|
||||
Return(&dashboards.Dashboard{ID: dashID, UID: "uid", Title: "Dash", Slug: "dash", Version: 2, FolderUID: folderUID, FolderID: folderID}, nil)
|
||||
// nolint:staticcheck
|
||||
mockFolderService := &foldertest.FakeService{
|
||||
ExpectedFolder: &folder.Folder{ID: 1, UID: folderUID, Title: "Folder"},
|
||||
}
|
||||
@@ -451,6 +452,7 @@ func TestDashboardAPIEndpoint(t *testing.T) {
|
||||
dashboardService.On("SaveDashboard", mock.Anything, mock.AnythingOfType("*dashboards.SaveDashboardDTO"), mock.AnythingOfType("bool")).
|
||||
Return(&dashboards.Dashboard{ID: dashID, UID: "uid", Title: "Dash", Slug: "dash", Version: 2}, nil)
|
||||
|
||||
// nolint:staticcheck
|
||||
mockFolder := &foldertest.FakeService{
|
||||
ExpectedFolder: &folder.Folder{ID: 1, UID: "folderUID", Title: "Folder"},
|
||||
}
|
||||
|
||||
+2
-2
@@ -62,7 +62,7 @@ func (hs *HTTPServer) GetFolders(c *contextmodel.ReqContext) response.Response {
|
||||
result := make([]dtos.FolderSearchHit, 0)
|
||||
for _, f := range folders {
|
||||
result = append(result, dtos.FolderSearchHit{
|
||||
Id: f.ID,
|
||||
Id: f.ID, // nolint:staticcheck
|
||||
Uid: f.UID,
|
||||
Title: f.Title,
|
||||
ParentUID: f.ParentUID,
|
||||
@@ -462,7 +462,7 @@ func (hs *HTTPServer) searchFolders(c *contextmodel.ReqContext) ([]*folder.Folde
|
||||
|
||||
for _, hit := range hits {
|
||||
folders = append(folders, &folder.Folder{
|
||||
ID: hit.ID,
|
||||
ID: hit.ID, // nolint:staticcheck
|
||||
UID: hit.UID,
|
||||
Title: hit.Title,
|
||||
})
|
||||
|
||||
@@ -94,7 +94,7 @@ func (hs *HTTPServer) UpdateFolderPermissions(c *contextmodel.ReqContext) respon
|
||||
for _, item := range apiCmd.Items {
|
||||
items = append(items, &dashboards.DashboardACL{
|
||||
OrgID: c.SignedInUser.GetOrgID(),
|
||||
DashboardID: folder.ID,
|
||||
DashboardID: folder.ID, // nolint:staticcheck
|
||||
UserID: item.UserID,
|
||||
TeamID: item.TeamID,
|
||||
Role: item.Role,
|
||||
@@ -146,7 +146,7 @@ func (hs *HTTPServer) getFolderACL(ctx context.Context, user identity.Requester,
|
||||
|
||||
acl = append(acl, &dashboards.DashboardACLInfoDTO{
|
||||
OrgID: folder.OrgID,
|
||||
DashboardID: folder.ID,
|
||||
DashboardID: folder.ID, // nolint:staticcheck
|
||||
FolderUID: folder.ParentUID,
|
||||
Created: p.Created,
|
||||
Updated: p.Updated,
|
||||
|
||||
@@ -30,6 +30,7 @@ func TestHTTPServer_GetFolderPermissionList(t *testing.T) {
|
||||
|
||||
t.Run("should be able to list acl with correct permission", func(t *testing.T) {
|
||||
server := SetupAPITestServer(t, func(hs *HTTPServer) {
|
||||
// nolint:staticcheck
|
||||
hs.folderService = &foldertest.FakeService{ExpectedFolder: &folder.Folder{ID: 1, UID: "1"}}
|
||||
hs.folderPermissionsService = &actest.FakePermissionsService{
|
||||
ExpectedPermissions: []accesscontrol.ResourcePermission{},
|
||||
@@ -50,6 +51,7 @@ func TestHTTPServer_GetFolderPermissionList(t *testing.T) {
|
||||
cfg := setting.NewCfg()
|
||||
cfg.HiddenUsers = map[string]struct{}{"hidden": {}}
|
||||
hs.Cfg = cfg
|
||||
// nolint:staticcheck
|
||||
hs.folderService = &foldertest.FakeService{ExpectedFolder: &folder.Folder{ID: 1, UID: "1"}}
|
||||
|
||||
hs.folderPermissionsService = &actest.FakePermissionsService{
|
||||
@@ -88,6 +90,7 @@ func TestHTTPServer_UpdateFolderPermissions(t *testing.T) {
|
||||
|
||||
t.Run("should be able to update acl with correct permissions", func(t *testing.T) {
|
||||
server := SetupAPITestServer(t, func(hs *HTTPServer) {
|
||||
// nolint:staticcheck
|
||||
hs.folderService = &foldertest.FakeService{ExpectedFolder: &folder.Folder{ID: 1, UID: "1"}}
|
||||
hs.folderPermissionsService = &actest.FakePermissionsService{}
|
||||
})
|
||||
@@ -104,6 +107,7 @@ func TestHTTPServer_UpdateFolderPermissions(t *testing.T) {
|
||||
|
||||
t.Run("should not be able to specify team and user in same acl", func(t *testing.T) {
|
||||
server := SetupAPITestServer(t, func(hs *HTTPServer) {
|
||||
// nolint:staticcheck
|
||||
hs.folderService = &foldertest.FakeService{ExpectedFolder: &folder.Folder{ID: 1, UID: "1"}}
|
||||
hs.folderPermissionsService = &actest.FakePermissionsService{}
|
||||
})
|
||||
@@ -120,6 +124,7 @@ func TestHTTPServer_UpdateFolderPermissions(t *testing.T) {
|
||||
|
||||
t.Run("should not be able to specify team and role in same acl", func(t *testing.T) {
|
||||
server := SetupAPITestServer(t, func(hs *HTTPServer) {
|
||||
// nolint:staticcheck
|
||||
hs.folderService = &foldertest.FakeService{ExpectedFolder: &folder.Folder{ID: 1, UID: "1"}}
|
||||
hs.folderPermissionsService = &actest.FakePermissionsService{}
|
||||
})
|
||||
@@ -136,6 +141,7 @@ func TestHTTPServer_UpdateFolderPermissions(t *testing.T) {
|
||||
|
||||
t.Run("should not be able to specify user and role in same acl", func(t *testing.T) {
|
||||
server := SetupAPITestServer(t, func(hs *HTTPServer) {
|
||||
// nolint:staticcheck
|
||||
hs.folderService = &foldertest.FakeService{ExpectedFolder: &folder.Folder{ID: 1, UID: "1"}}
|
||||
hs.folderPermissionsService = &actest.FakePermissionsService{}
|
||||
})
|
||||
|
||||
@@ -47,7 +47,7 @@ func TestFoldersCreateAPIEndpoint(t *testing.T) {
|
||||
description: "folder creation succeeds given the correct request for creating a folder",
|
||||
input: folderWithoutParentInput,
|
||||
expectedCode: http.StatusOK,
|
||||
expectedFolder: &folder.Folder{ID: 1, UID: "uid", Title: "Folder"},
|
||||
expectedFolder: &folder.Folder{ID: 1, UID: "uid", Title: "Folder"}, // nolint:staticcheck
|
||||
permissions: []accesscontrol.Permission{{Action: dashboards.ActionFoldersCreate}},
|
||||
},
|
||||
{
|
||||
@@ -169,7 +169,7 @@ func TestFoldersUpdateAPIEndpoint(t *testing.T) {
|
||||
{
|
||||
description: "folder updating succeeds given the correct request and permissions to update a folder",
|
||||
expectedCode: http.StatusOK,
|
||||
expectedFolder: &folder.Folder{ID: 1, UID: "uid", Title: "Folder upd"},
|
||||
expectedFolder: &folder.Folder{ID: 1, UID: "uid", Title: "Folder upd"}, // nolint:staticcheck
|
||||
permissions: []accesscontrol.Permission{{Action: dashboards.ActionFoldersWrite, Scope: dashboards.ScopeFoldersAll}},
|
||||
},
|
||||
{
|
||||
@@ -421,7 +421,7 @@ func TestFolderMoveAPIEndpoint(t *testing.T) {
|
||||
func TestFolderGetAPIEndpoint(t *testing.T) {
|
||||
folderService := &foldertest.FakeService{
|
||||
ExpectedFolder: &folder.Folder{
|
||||
ID: 1,
|
||||
ID: 1, // nolint:staticcheck
|
||||
UID: "uid",
|
||||
Title: "uid title",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user