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:
Kat Yang
2023-11-20 15:44:51 -05:00
committed by GitHub
parent ae164df698
commit 2f2ce3edbb
34 changed files with 128 additions and 20 deletions
@@ -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)