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:
@@ -44,6 +44,7 @@ func TestIntegrationDashboardFolderStore(t *testing.T) {
|
||||
t.Run("GetFolderByTitle should find the folder", func(t *testing.T) {
|
||||
result, err := folderStore.GetFolderByTitle(context.Background(), orgId, title)
|
||||
require.NoError(t, err)
|
||||
// nolint:staticcheck
|
||||
require.Equal(t, folder1.ID, result.ID)
|
||||
})
|
||||
})
|
||||
@@ -57,6 +58,7 @@ func TestIntegrationDashboardFolderStore(t *testing.T) {
|
||||
|
||||
t.Run("should return folder by UID", func(t *testing.T) {
|
||||
d, err := folderStore.GetFolderByUID(context.Background(), orgId, folder.UID)
|
||||
// nolint:staticcheck
|
||||
require.Equal(t, folder.ID, d.ID)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
@@ -81,6 +83,7 @@ func TestIntegrationDashboardFolderStore(t *testing.T) {
|
||||
|
||||
t.Run("should return folder by ID", func(t *testing.T) {
|
||||
d, err := folderStore.GetFolderByID(context.Background(), orgId, folder.ID)
|
||||
// nolint:staticcheck
|
||||
require.Equal(t, folder.ID, d.ID)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
@@ -173,6 +173,7 @@ func (s *Service) Get(ctx context.Context, cmd *folder.GetFolderQuery) (*folder.
|
||||
}
|
||||
|
||||
// always expose the dashboard store sequential ID
|
||||
// nolint:staticcheck
|
||||
f.ID = dashFolder.ID
|
||||
f.Version = dashFolder.Version
|
||||
|
||||
@@ -225,6 +226,7 @@ func (s *Service) GetChildren(ctx context.Context, cmd *folder.GetChildrenQuery)
|
||||
}
|
||||
|
||||
// always expose the dashboard store sequential ID
|
||||
// nolint:staticcheck
|
||||
f.ID = dashFolder.ID
|
||||
|
||||
if cmd.UID != "" {
|
||||
@@ -443,7 +445,7 @@ func (s *Service) Create(ctx context.Context, cmd *folder.CreateFolderCommand) (
|
||||
logger.Error("error saving folder to nested folder store", "error", err)
|
||||
// do not shallow create error if the legacy folder delete fails
|
||||
if deleteErr := s.dashboardStore.DeleteDashboard(ctx, &dashboards.DeleteDashboardCommand{
|
||||
ID: createdFolder.ID,
|
||||
ID: createdFolder.ID, // nolint:staticcheck
|
||||
OrgID: createdFolder.OrgID,
|
||||
}); deleteErr != nil {
|
||||
logger.Error("error deleting folder after failed save to nested folder store", "error", err)
|
||||
@@ -488,6 +490,7 @@ func (s *Service) Update(ctx context.Context, cmd *folder.UpdateFolderCommand) (
|
||||
}
|
||||
|
||||
// always expose the dashboard store sequential ID
|
||||
// nolint:staticcheck
|
||||
foldr.ID = dashFolder.ID
|
||||
foldr.Version = dashFolder.Version
|
||||
|
||||
@@ -660,6 +663,7 @@ func (s *Service) deleteChildrenInFolder(ctx context.Context, orgID int64, folde
|
||||
}
|
||||
|
||||
func (s *Service) legacyDelete(ctx context.Context, cmd *folder.DeleteFolderCommand, dashFolder *folder.Folder) error {
|
||||
// nolint:staticcheck
|
||||
deleteCmd := dashboards.DeleteDashboardCommand{OrgID: cmd.OrgID, ID: dashFolder.ID, ForceDeleteFolderRules: cmd.ForceDeleteRules}
|
||||
|
||||
if err := s.dashboardStore.DeleteDashboard(ctx, &deleteCmd); err != nil {
|
||||
|
||||
@@ -94,6 +94,7 @@ func TestIntegrationFolderService(t *testing.T) {
|
||||
folderUID := util.GenerateShortUID()
|
||||
|
||||
f := folder.NewFolder("Folder", "")
|
||||
// nolint:staticcheck
|
||||
f.ID = folderId
|
||||
f.UID = folderUID
|
||||
|
||||
@@ -117,6 +118,7 @@ func TestIntegrationFolderService(t *testing.T) {
|
||||
SignedInUser: usr,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// nolint:staticcheck
|
||||
require.Equal(t, foldr, &folder.Folder{ID: 0, Title: "General"})
|
||||
})
|
||||
|
||||
@@ -239,6 +241,7 @@ func TestIntegrationFolderService(t *testing.T) {
|
||||
|
||||
t.Run("When deleting folder by uid should not return access denied error", func(t *testing.T) {
|
||||
f := folder.NewFolder(util.GenerateShortUID(), "")
|
||||
// nolint:staticcheck
|
||||
f.ID = rand.Int63()
|
||||
f.UID = util.GenerateShortUID()
|
||||
folderStore.On("GetFolders", mock.Anything, orgID, []string{f.UID}).Return(map[string]*folder.Folder{f.UID: f}, nil)
|
||||
@@ -258,6 +261,7 @@ func TestIntegrationFolderService(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, actualCmd)
|
||||
// nolint:staticcheck
|
||||
require.Equal(t, f.ID, actualCmd.ID)
|
||||
require.Equal(t, orgID, actualCmd.OrgID)
|
||||
require.Equal(t, expectedForceDeleteRules, actualCmd.ForceDeleteFolderRules)
|
||||
@@ -274,10 +278,13 @@ func TestIntegrationFolderService(t *testing.T) {
|
||||
|
||||
t.Run("When get folder by id should return folder", func(t *testing.T) {
|
||||
expected := folder.NewFolder(util.GenerateShortUID(), "")
|
||||
// nolint:staticcheck
|
||||
expected.ID = rand.Int63()
|
||||
|
||||
// nolint:staticcheck
|
||||
folderStore.On("GetFolderByID", mock.Anything, orgID, expected.ID).Return(expected, nil)
|
||||
|
||||
// nolint:staticcheck
|
||||
actual, err := service.getFolderByID(context.Background(), expected.ID, orgID)
|
||||
require.Equal(t, expected, actual)
|
||||
require.NoError(t, err)
|
||||
@@ -418,7 +425,9 @@ func TestIntegrationNestedFolderService(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
subfolder, err := serviceWithFlagOn.dashboardFolderStore.GetFolderByUID(context.Background(), orgID, ancestorUIDs[1])
|
||||
require.NoError(t, err)
|
||||
// nolint:staticcheck
|
||||
_ = insertTestDashboard(t, serviceWithFlagOn.dashboardStore, "dashboard in parent", orgID, parent.ID, parent.UID, "prod")
|
||||
// nolint:staticcheck
|
||||
_ = insertTestDashboard(t, serviceWithFlagOn.dashboardStore, "dashboard in subfolder", orgID, subfolder.ID, subfolder.UID, "prod")
|
||||
_ = createRule(t, alertStore, parent.UID, "parent alert")
|
||||
_ = createRule(t, alertStore, subfolder.UID, "sub alert")
|
||||
@@ -495,7 +504,9 @@ func TestIntegrationNestedFolderService(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
subfolder, err := serviceWithFlagOn.dashboardFolderStore.GetFolderByUID(context.Background(), orgID, ancestorUIDs[1])
|
||||
require.NoError(t, err)
|
||||
// nolint:staticcheck
|
||||
_ = insertTestDashboard(t, serviceWithFlagOn.dashboardStore, "dashboard in parent", orgID, parent.ID, parent.UID, "prod")
|
||||
// nolint:staticcheck
|
||||
_ = insertTestDashboard(t, serviceWithFlagOn.dashboardStore, "dashboard in subfolder", orgID, subfolder.ID, subfolder.UID, "prod")
|
||||
_ = createRule(t, alertStore, parent.UID, "parent alert")
|
||||
_ = createRule(t, alertStore, subfolder.UID, "sub alert")
|
||||
@@ -1205,6 +1216,7 @@ func CreateSubtreeInStore(t *testing.T, store *sqlStore, service *Service, depth
|
||||
f, err := service.Create(context.Background(), &cmd)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, title, f.Title)
|
||||
// nolint:staticcheck
|
||||
require.NotEmpty(t, f.ID)
|
||||
require.NotEmpty(t, f.UID)
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ func TestIntegrationCreate(t *testing.T) {
|
||||
|
||||
assert.Equal(t, folderTitle, f.Title)
|
||||
assert.Equal(t, folderDsc, f.Description)
|
||||
// nolint:staticcheck
|
||||
assert.NotEmpty(t, f.ID)
|
||||
assert.Equal(t, uid, f.UID)
|
||||
assert.Empty(t, f.ParentUID)
|
||||
@@ -97,6 +98,7 @@ func TestIntegrationCreate(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, "parent", parent.Title)
|
||||
// nolint:staticcheck
|
||||
require.NotEmpty(t, parent.ID)
|
||||
assert.Equal(t, parentUID, parent.UID)
|
||||
assert.NotEmpty(t, parent.URL)
|
||||
@@ -123,6 +125,7 @@ func TestIntegrationCreate(t *testing.T) {
|
||||
|
||||
assert.Equal(t, folderTitle, f.Title)
|
||||
assert.Equal(t, folderDsc, f.Description)
|
||||
// nolint:staticcheck
|
||||
assert.NotEmpty(t, f.ID)
|
||||
assert.Equal(t, uid, f.UID)
|
||||
assert.Equal(t, parentUID, f.ParentUID)
|
||||
@@ -401,6 +404,7 @@ func TestIntegrationGet(t *testing.T) {
|
||||
OrgID: orgID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// nolint:staticcheck
|
||||
assert.Equal(t, f.ID, ff.ID)
|
||||
assert.Equal(t, f.UID, ff.UID)
|
||||
assert.Equal(t, f.OrgID, ff.OrgID)
|
||||
@@ -418,6 +422,7 @@ func TestIntegrationGet(t *testing.T) {
|
||||
OrgID: orgID,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// nolint:staticcheck
|
||||
assert.Equal(t, f.ID, ff.ID)
|
||||
assert.Equal(t, f.UID, ff.UID)
|
||||
assert.Equal(t, f.OrgID, ff.OrgID)
|
||||
@@ -434,6 +439,7 @@ func TestIntegrationGet(t *testing.T) {
|
||||
ID: &f.ID, // nolint:staticcheck
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// nolint:staticcheck
|
||||
assert.Equal(t, f.ID, ff.ID)
|
||||
assert.Equal(t, f.UID, ff.UID)
|
||||
assert.Equal(t, f.OrgID, ff.OrgID)
|
||||
@@ -751,6 +757,7 @@ func TestIntegrationGetFolders(t *testing.T) {
|
||||
})
|
||||
assert.NotEqual(t, -1, folderInResponseIdx)
|
||||
rf := ff[folderInResponseIdx]
|
||||
// nolint:staticcheck
|
||||
assert.Equal(t, f.ID, rf.ID)
|
||||
assert.Equal(t, f.OrgID, rf.OrgID)
|
||||
assert.Equal(t, f.Title, rf.Title)
|
||||
@@ -795,6 +802,7 @@ func CreateSubtree(t *testing.T, store *sqlStore, orgID int64, parentUID string,
|
||||
f, err := store.Create(context.Background(), cmd)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, title, f.Title)
|
||||
// nolint:staticcheck
|
||||
require.NotEmpty(t, f.ID)
|
||||
require.NotEmpty(t, f.UID)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user