Remove folderID from service tests (#80615)
* Remove folderID from service tests * Remove folderID from ngalert migration tests * Remove tests related to folderIDs * Roll back change Before removing FolderID from this test, we need to adjust the code * Remove FolderID from publicdashboard pkg * Add back annotations test
This commit is contained in:
@@ -128,7 +128,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
Dashboard: simplejson.NewFromAny(map[string]any{
|
||||
"title": "Dash",
|
||||
}),
|
||||
FolderID: sc.otherSavedFolder.ID, // nolint:staticcheck
|
||||
FolderUID: sc.otherSavedFolder.UID,
|
||||
UserID: 10000,
|
||||
Overwrite: true,
|
||||
@@ -152,7 +151,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
Dashboard: simplejson.NewFromAny(map[string]any{
|
||||
"title": sc.savedDashInFolder.Title,
|
||||
}),
|
||||
FolderID: sc.savedFolder.ID, // nolint:staticcheck
|
||||
FolderUID: sc.savedFolder.UID,
|
||||
UserID: 10000,
|
||||
Overwrite: true,
|
||||
@@ -177,7 +175,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"uid": sc.savedDashInFolder.UID,
|
||||
"title": "New dash",
|
||||
}),
|
||||
FolderID: sc.savedFolder.ID, // nolint:staticcheck
|
||||
FolderUID: sc.savedFolder.UID,
|
||||
UserID: 10000,
|
||||
Overwrite: true,
|
||||
@@ -202,7 +199,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"id": sc.savedDashInGeneralFolder.ID,
|
||||
"title": "Dash",
|
||||
}),
|
||||
FolderID: sc.savedDashInGeneralFolder.FolderID, // nolint:staticcheck
|
||||
FolderUID: sc.savedDashInGeneralFolder.FolderUID,
|
||||
UserID: 10000,
|
||||
Overwrite: true,
|
||||
@@ -227,7 +223,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"id": sc.savedDashInFolder.ID,
|
||||
"title": "Dash",
|
||||
}),
|
||||
FolderID: sc.savedDashInFolder.FolderID, // nolint:staticcheck
|
||||
FolderUID: sc.savedDashInFolder.FolderUID,
|
||||
UserID: 10000,
|
||||
Overwrite: true,
|
||||
@@ -252,7 +247,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"id": sc.savedDashInGeneralFolder.ID,
|
||||
"title": "Dash",
|
||||
}),
|
||||
FolderID: sc.otherSavedFolder.ID, // nolint:staticcheck
|
||||
FolderUID: sc.otherSavedFolder.UID,
|
||||
UserID: 10000,
|
||||
Overwrite: true,
|
||||
@@ -277,7 +271,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"id": sc.savedDashInFolder.ID,
|
||||
"title": "Dash",
|
||||
}),
|
||||
FolderID: 0, // nolint:staticcheck
|
||||
FolderUID: "",
|
||||
UserID: 10000,
|
||||
Overwrite: true,
|
||||
@@ -302,7 +295,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"uid": sc.savedDashInGeneralFolder.UID,
|
||||
"title": "Dash",
|
||||
}),
|
||||
FolderID: sc.otherSavedFolder.ID, // nolint:staticcheck
|
||||
FolderUID: sc.otherSavedFolder.UID,
|
||||
UserID: 10000,
|
||||
Overwrite: true,
|
||||
@@ -327,7 +319,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"uid": sc.savedDashInFolder.UID,
|
||||
"title": "Dash",
|
||||
}),
|
||||
FolderID: 0, // nolint:staticcheck
|
||||
FolderUID: "",
|
||||
UserID: 10000,
|
||||
Overwrite: true,
|
||||
@@ -359,7 +350,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"id": nil,
|
||||
"title": sc.savedDashInFolder.Title,
|
||||
}),
|
||||
FolderID: 0, // nolint:staticcheck
|
||||
FolderUID: "",
|
||||
Overwrite: shouldOverwrite,
|
||||
}
|
||||
@@ -383,7 +373,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"id": nil,
|
||||
"title": sc.savedDashInGeneralFolder.Title,
|
||||
}),
|
||||
FolderID: sc.savedFolder.ID, // nolint:staticcheck
|
||||
FolderUID: sc.savedFolder.UID,
|
||||
Overwrite: shouldOverwrite,
|
||||
}
|
||||
@@ -475,7 +464,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
Dashboard: simplejson.NewFromAny(map[string]any{
|
||||
"title": "Expect error",
|
||||
}),
|
||||
FolderID: 123412321, // nolint:staticcheck
|
||||
FolderUID: "123412321",
|
||||
Overwrite: shouldOverwrite,
|
||||
}
|
||||
@@ -492,7 +480,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"id": sc.savedDashInGeneralFolder.ID,
|
||||
"title": "test dash 23",
|
||||
}),
|
||||
FolderID: sc.savedFolder.ID, // nolint:staticcheck
|
||||
FolderUID: sc.savedFolder.UID,
|
||||
Overwrite: shouldOverwrite,
|
||||
}
|
||||
@@ -510,7 +497,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"title": "Updated title",
|
||||
"version": sc.savedDashInGeneralFolder.Version,
|
||||
}),
|
||||
FolderID: sc.savedFolder.ID, // nolint:staticcheck
|
||||
FolderUID: sc.savedFolder.UID,
|
||||
Overwrite: shouldOverwrite,
|
||||
}
|
||||
@@ -534,7 +520,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"uid": sc.savedDashInFolder.UID,
|
||||
"title": "test dash 23",
|
||||
}),
|
||||
FolderID: 0, // nolint:staticcheck
|
||||
FolderUID: "",
|
||||
Overwrite: shouldOverwrite,
|
||||
}
|
||||
@@ -552,7 +537,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"title": "Updated title",
|
||||
"version": sc.savedDashInFolder.Version,
|
||||
}),
|
||||
FolderID: 0, // nolint:staticcheck
|
||||
FolderUID: "",
|
||||
Overwrite: shouldOverwrite,
|
||||
}
|
||||
@@ -575,7 +559,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"id": nil,
|
||||
"title": sc.savedDashInFolder.Title,
|
||||
}),
|
||||
FolderID: sc.savedDashInFolder.FolderID, // nolint:staticcheck
|
||||
FolderUID: sc.savedDashInFolder.FolderUID,
|
||||
Overwrite: shouldOverwrite,
|
||||
}
|
||||
@@ -592,7 +575,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"id": nil,
|
||||
"title": sc.savedDashInGeneralFolder.Title,
|
||||
}),
|
||||
FolderID: sc.savedDashInGeneralFolder.FolderID, // nolint:staticcheck
|
||||
FolderUID: sc.savedDashInGeneralFolder.FolderUID,
|
||||
Overwrite: shouldOverwrite,
|
||||
}
|
||||
@@ -629,7 +611,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"id": sc.savedDashInGeneralFolder.ID,
|
||||
"title": "Updated title",
|
||||
}),
|
||||
FolderID: sc.savedFolder.ID, // nolint:staticcheck
|
||||
FolderUID: sc.savedFolder.UID,
|
||||
Overwrite: shouldOverwrite,
|
||||
}
|
||||
@@ -652,7 +633,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"uid": sc.savedDashInFolder.UID,
|
||||
"title": "Updated title",
|
||||
}),
|
||||
FolderID: 0, // nolint:staticcheck
|
||||
FolderUID: "",
|
||||
Overwrite: shouldOverwrite,
|
||||
}
|
||||
@@ -715,7 +695,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"id": nil,
|
||||
"title": sc.savedDashInFolder.Title,
|
||||
}),
|
||||
FolderID: sc.savedDashInFolder.FolderID, // nolint:staticcheck
|
||||
FolderUID: sc.savedDashInFolder.FolderUID,
|
||||
Overwrite: shouldOverwrite,
|
||||
}
|
||||
@@ -740,7 +719,6 @@ func TestIntegrationIntegratedDashboardService(t *testing.T) {
|
||||
"id": nil,
|
||||
"title": sc.savedDashInGeneralFolder.Title,
|
||||
}),
|
||||
FolderID: sc.savedDashInGeneralFolder.FolderID, // nolint:staticcheck
|
||||
FolderUID: sc.savedDashInGeneralFolder.FolderUID,
|
||||
Overwrite: shouldOverwrite,
|
||||
}
|
||||
@@ -899,25 +877,21 @@ func permissionScenario(t *testing.T, desc string, canSave bool, fn permissionSc
|
||||
guardian.InitAccessControlGuardian(cfg, ac, dashboardService)
|
||||
|
||||
savedFolder := saveTestFolder(t, "Saved folder", testOrgID, sqlStore)
|
||||
savedDashInFolder := saveTestDashboard(t, "Saved dash in folder", testOrgID, savedFolder.ID, savedFolder.UID, sqlStore)
|
||||
saveTestDashboard(t, "Other saved dash in folder", testOrgID, savedFolder.ID, savedFolder.UID, sqlStore)
|
||||
savedDashInGeneralFolder := saveTestDashboard(t, "Saved dashboard in general folder", testOrgID, 0, "", sqlStore)
|
||||
savedDashInFolder := saveTestDashboard(t, "Saved dash in folder", testOrgID, savedFolder.UID, sqlStore)
|
||||
saveTestDashboard(t, "Other saved dash in folder", testOrgID, savedFolder.UID, sqlStore)
|
||||
savedDashInGeneralFolder := saveTestDashboard(t, "Saved dashboard in general folder", testOrgID, "", sqlStore)
|
||||
otherSavedFolder := saveTestFolder(t, "Other saved folder", testOrgID, sqlStore)
|
||||
|
||||
require.Equal(t, "Saved folder", savedFolder.Title)
|
||||
require.Equal(t, "saved-folder", savedFolder.Slug)
|
||||
require.NotEqual(t, int64(0), savedFolder.ID)
|
||||
require.True(t, savedFolder.IsFolder)
|
||||
// nolint:staticcheck
|
||||
require.Equal(t, int64(0), savedFolder.FolderID)
|
||||
require.NotEmpty(t, savedFolder.UID)
|
||||
|
||||
require.Equal(t, "Saved dash in folder", savedDashInFolder.Title)
|
||||
require.Equal(t, "saved-dash-in-folder", savedDashInFolder.Slug)
|
||||
require.NotEqual(t, int64(0), savedDashInFolder.ID)
|
||||
require.False(t, savedDashInFolder.IsFolder)
|
||||
// nolint:staticcheck
|
||||
require.Equal(t, savedFolder.ID, savedDashInFolder.FolderID)
|
||||
require.NotEmpty(t, savedDashInFolder.UID)
|
||||
|
||||
origNewDashboardGuardian := guardian.New
|
||||
@@ -993,12 +967,11 @@ func callSaveWithError(t *testing.T, cmd dashboards.SaveDashboardCommand, sqlSto
|
||||
return err
|
||||
}
|
||||
|
||||
func saveTestDashboard(t *testing.T, title string, orgID, folderID int64, folderUID string, sqlStore db.DB) *dashboards.Dashboard {
|
||||
func saveTestDashboard(t *testing.T, title string, orgID int64, folderUID string, sqlStore db.DB) *dashboards.Dashboard {
|
||||
t.Helper()
|
||||
|
||||
cmd := dashboards.SaveDashboardCommand{
|
||||
OrgID: orgID,
|
||||
FolderID: folderID, // nolint:staticcheck
|
||||
FolderUID: folderUID,
|
||||
IsFolder: false,
|
||||
Dashboard: simplejson.NewFromAny(map[string]any{
|
||||
@@ -1044,7 +1017,6 @@ func saveTestFolder(t *testing.T, title string, orgID int64, sqlStore db.DB) *da
|
||||
t.Helper()
|
||||
cmd := dashboards.SaveDashboardCommand{
|
||||
OrgID: orgID,
|
||||
FolderID: 0, // nolint:staticcheck
|
||||
FolderUID: "",
|
||||
IsFolder: true,
|
||||
Dashboard: simplejson.NewFromAny(map[string]any{
|
||||
|
||||
Reference in New Issue
Block a user