mirror of
https://github.com/grafana/grafana.git
synced 2026-07-30 08:18:10 -05:00
Remove some folderIDs from database test (#81643)
* Remove some folderIDs from database test * Add folderUID to insertTestDashboardForPlugin
This commit is contained in:
@@ -502,7 +502,6 @@ func TestIntegrationDashboardDataAccess(t *testing.T) {
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
// nolint:staticcheck
|
||||
count, err := dashboardStore.CountDashboardsInFolders(context.Background(), &dashboards.CountDashboardsInFolderRequest{FolderUIDs: []string{folder.UID}, OrgID: 1})
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, count, int64(0))
|
||||
@@ -519,9 +518,10 @@ func TestIntegrationDashboardDataAccessGivenPluginWithImportedDashboards(t *test
|
||||
require.NoError(t, err)
|
||||
pluginId := "test-app"
|
||||
|
||||
appFolder := insertTestDashboardForPlugin(t, dashboardStore, "app-test", 1, 0, true, pluginId)
|
||||
insertTestDashboardForPlugin(t, dashboardStore, "app-dash1", 1, appFolder.ID, false, pluginId)
|
||||
insertTestDashboardForPlugin(t, dashboardStore, "app-dash2", 1, appFolder.ID, false, pluginId)
|
||||
insertTestDashboardForPlugin(t, dashboardStore, "app-test", 1, "", true, pluginId)
|
||||
insertTestDashboardForPlugin(t, dashboardStore, "app-test", 1, "", true, pluginId)
|
||||
insertTestDashboardForPlugin(t, dashboardStore, "app-dash1", 1, "", false, pluginId)
|
||||
insertTestDashboardForPlugin(t, dashboardStore, "app-dash2", 1, "", false, pluginId)
|
||||
|
||||
query := dashboards.GetDashboardsByPluginIDQuery{
|
||||
PluginID: pluginId,
|
||||
@@ -658,8 +658,7 @@ func TestGetExistingDashboardByTitleAndFolder(t *testing.T) {
|
||||
savedFolder := insertTestDashboard(t, dashboardStore, "test dash folder", 1, 0, "", true, "prod", "webapp")
|
||||
savedDash := insertTestDashboard(t, dashboardStore, "test dash", 1, savedFolder.ID, savedFolder.UID, false, "prod", "webapp")
|
||||
err = sqlStore.WithDbSession(context.Background(), func(sess *sqlstore.DBSession) error {
|
||||
// nolint:staticcheck
|
||||
_, err = getExistingDashboardByTitleAndFolder(sess, &dashboards.Dashboard{Title: savedDash.Title, FolderID: savedFolder.ID, FolderUID: savedFolder.UID, OrgID: 1}, sqlStore.GetDialect(), false, false)
|
||||
_, err = getExistingDashboardByTitleAndFolder(sess, &dashboards.Dashboard{Title: savedDash.Title, FolderUID: savedFolder.UID, OrgID: 1}, sqlStore.GetDialect(), false, false)
|
||||
return err
|
||||
})
|
||||
require.ErrorIs(t, err, dashboards.ErrDashboardWithSameNameInFolderExists)
|
||||
@@ -713,8 +712,8 @@ func TestIntegrationFindDashboardsByTitle(t *testing.T) {
|
||||
SignedInUser: user,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// nolint:staticcheck
|
||||
insertTestDashboard(t, dashboardStore, "dashboard under f0", orgID, f0.ID, f0.UID, false)
|
||||
|
||||
insertTestDashboard(t, dashboardStore, "dashboard under f0", orgID, 0, f0.UID, false)
|
||||
|
||||
subfolder, err := folderServiceWithFlagOn.Create(context.Background(), &folder.CreateFolderCommand{
|
||||
OrgID: orgID,
|
||||
@@ -723,8 +722,8 @@ func TestIntegrationFindDashboardsByTitle(t *testing.T) {
|
||||
SignedInUser: user,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
// nolint:staticcheck
|
||||
insertTestDashboard(t, dashboardStore, "dashboard under subfolder", orgID, subfolder.ID, subfolder.UID, false)
|
||||
|
||||
insertTestDashboard(t, dashboardStore, "dashboard under subfolder", orgID, 0, subfolder.UID, false)
|
||||
|
||||
type res struct {
|
||||
title string
|
||||
@@ -1065,12 +1064,12 @@ func insertTestDashboard(t *testing.T, dashboardStore dashboards.Store, title st
|
||||
}
|
||||
|
||||
func insertTestDashboardForPlugin(t *testing.T, dashboardStore dashboards.Store, title string, orgId int64,
|
||||
folderId int64, isFolder bool, pluginId string) *dashboards.Dashboard {
|
||||
folderUID string, isFolder bool, pluginId string) *dashboards.Dashboard {
|
||||
t.Helper()
|
||||
cmd := dashboards.SaveDashboardCommand{
|
||||
OrgID: orgId,
|
||||
FolderID: folderId, // nolint:staticcheck
|
||||
IsFolder: isFolder,
|
||||
OrgID: orgId,
|
||||
IsFolder: isFolder,
|
||||
FolderUID: folderUID,
|
||||
Dashboard: simplejson.NewFromAny(map[string]interface{}{
|
||||
"id": nil,
|
||||
"title": title,
|
||||
|
||||
Reference in New Issue
Block a user