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:
idafurjes
2024-01-26 17:36:35 +02:00
committed by GitHub
parent 04396c001a
commit f44592a97a
13 changed files with 144 additions and 604 deletions
@@ -37,9 +37,9 @@ func TestIntegrationDashboardFolderStore(t *testing.T) {
var folder1, folder2 *dashboards.Dashboard
sqlStore = db.InitTestDB(t)
folderStore := ProvideDashboardFolderStore(sqlStore)
folder2 = insertTestFolder(t, dashboardStore, "TEST", orgId, 0, "", "prod")
folder2 = insertTestFolder(t, dashboardStore, "TEST", orgId, "", "prod")
_ = insertTestDashboard(t, dashboardStore, title, orgId, folder2.ID, folder2.UID, "prod")
folder1 = insertTestFolder(t, dashboardStore, title, orgId, 0, "", "prod")
folder1 = insertTestFolder(t, dashboardStore, title, orgId, "", "prod")
t.Run("GetFolderByTitle should find the folder", func(t *testing.T) {
result, err := folderStore.GetFolderByTitle(context.Background(), orgId, title, nil)
@@ -48,7 +48,7 @@ func TestIntegrationDashboardFolderStore(t *testing.T) {
})
t.Run("GetFolderByTitle should find the folder by folderUID", func(t *testing.T) {
folder3 := insertTestFolder(t, dashboardStore, title, orgId, folder2.ID, folder2.UID, "prod")
folder3 := insertTestFolder(t, dashboardStore, title, orgId, folder2.UID, "prod")
result, err := folderStore.GetFolderByTitle(context.Background(), orgId, title, &folder2.UID)
require.NoError(t, err)
require.Equal(t, folder3.UID, result.UID)
@@ -60,7 +60,7 @@ func TestIntegrationDashboardFolderStore(t *testing.T) {
var orgId int64 = 1
sqlStore := db.InitTestDB(t)
folderStore := ProvideDashboardFolderStore(sqlStore)
folder := insertTestFolder(t, dashboardStore, "TEST", orgId, 0, "", "prod")
folder := insertTestFolder(t, dashboardStore, "TEST", orgId, "", "prod")
dash := insertTestDashboard(t, dashboardStore, "Very Unique Name", orgId, folder.ID, folder.UID, "prod")
t.Run("should return folder by UID", func(t *testing.T) {
@@ -85,7 +85,7 @@ func TestIntegrationDashboardFolderStore(t *testing.T) {
var orgId int64 = 1
sqlStore := db.InitTestDB(t)
folderStore := ProvideDashboardFolderStore(sqlStore)
folder := insertTestFolder(t, dashboardStore, "TEST", orgId, 0, "", "prod")
folder := insertTestFolder(t, dashboardStore, "TEST", orgId, "", "prod")
dash := insertTestDashboard(t, dashboardStore, "Very Unique Name", orgId, folder.ID, folder.UID, "prod")
t.Run("should return folder by ID", func(t *testing.T) {
@@ -106,12 +106,13 @@ func TestIntegrationDashboardFolderStore(t *testing.T) {
})
}
func insertTestDashboard(t *testing.T, dashboardStore dashboards.Store, title string, orgId int64, folderID int64, folderUID string, tags ...any) *dashboards.Dashboard {
func insertTestDashboard(t *testing.T, dashboardStore dashboards.Store, title string, orgId, folderID int64, folderUID string, tags ...any) *dashboards.Dashboard {
t.Helper()
cmd := dashboards.SaveDashboardCommand{
OrgID: orgId,
FolderID: folderID, // nolint:staticcheck
IsFolder: false,
OrgID: orgId,
FolderUID: folderUID,
FolderID: folderID, // nolint:staticcheck
IsFolder: false,
Dashboard: simplejson.NewFromAny(map[string]any{
"id": nil,
"title": title,
@@ -129,12 +130,13 @@ func insertTestDashboard(t *testing.T, dashboardStore dashboards.Store, title st
return dash
}
func insertTestFolder(t *testing.T, dashboardStore dashboards.Store, title string, orgId int64, folderId int64, folderUID string, tags ...any) *dashboards.Dashboard {
func insertTestFolder(t *testing.T, dashboardStore dashboards.Store, title string, orgId int64, folderUID string, tags ...any) *dashboards.Dashboard {
t.Helper()
cmd := dashboards.SaveDashboardCommand{
OrgID: orgId,
FolderID: folderId, // nolint:staticcheck
IsFolder: true,
OrgID: orgId,
// FolderID: folderId, // nolint:staticcheck
FolderUID: folderUID,
IsFolder: true,
Dashboard: simplejson.NewFromAny(map[string]any{
"id": nil,
"title": title,