Chore: Move folder store interface, implementation and test under pkg/services/folder (#62586)
* Chore: Move folder store into folder service package * Split folder and dashboard store implementations
This commit is contained in:
@@ -474,78 +474,6 @@ func TestIntegrationDashboardFolderDataAccess(t *testing.T) {
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("Given dashboard and folder with the same title", func(t *testing.T) {
|
||||
var orgId int64 = 1
|
||||
title := "Very Unique Name"
|
||||
var sqlStore *sqlstore.SQLStore
|
||||
var folder1, folder2 *dashboards.Dashboard
|
||||
sqlStore = db.InitTestDB(t)
|
||||
quotaService := quotatest.New(false, nil)
|
||||
dashboardStore, err := ProvideDashboardStore(sqlStore, sqlStore.Cfg, testFeatureToggles, tagimpl.ProvideService(sqlStore, sqlStore.Cfg), quotaService)
|
||||
require.NoError(t, err)
|
||||
folder2 = insertTestDashboard(t, dashboardStore, "TEST", orgId, 0, true, "prod")
|
||||
_ = insertTestDashboard(t, dashboardStore, title, orgId, folder2.ID, false, "prod")
|
||||
folder1 = insertTestDashboard(t, dashboardStore, title, orgId, 0, true, "prod")
|
||||
|
||||
t.Run("GetFolderByTitle should find the folder", func(t *testing.T) {
|
||||
result, err := dashboardStore.GetFolderByTitle(context.Background(), orgId, title)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, folder1.ID, result.ID)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("GetFolderByUID", func(t *testing.T) {
|
||||
var orgId int64 = 1
|
||||
sqlStore := db.InitTestDB(t)
|
||||
quotaService := quotatest.New(false, nil)
|
||||
dashboardStore, err := ProvideDashboardStore(sqlStore, sqlStore.Cfg, testFeatureToggles, tagimpl.ProvideService(sqlStore, sqlStore.Cfg), quotaService)
|
||||
require.NoError(t, err)
|
||||
folder := insertTestDashboard(t, dashboardStore, "TEST", orgId, 0, true, "prod")
|
||||
dash := insertTestDashboard(t, dashboardStore, "Very Unique Name", orgId, folder.ID, false, "prod")
|
||||
|
||||
t.Run("should return folder by UID", func(t *testing.T) {
|
||||
d, err := dashboardStore.GetFolderByUID(context.Background(), orgId, folder.UID)
|
||||
require.Equal(t, folder.ID, d.ID)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
t.Run("should not find dashboard", func(t *testing.T) {
|
||||
d, err := dashboardStore.GetFolderByUID(context.Background(), orgId, dash.UID)
|
||||
require.Nil(t, d)
|
||||
require.ErrorIs(t, err, dashboards.ErrFolderNotFound)
|
||||
})
|
||||
t.Run("should search in organization", func(t *testing.T) {
|
||||
d, err := dashboardStore.GetFolderByUID(context.Background(), orgId+1, folder.UID)
|
||||
require.Nil(t, d)
|
||||
require.ErrorIs(t, err, dashboards.ErrFolderNotFound)
|
||||
})
|
||||
})
|
||||
|
||||
t.Run("GetFolderByID", func(t *testing.T) {
|
||||
var orgId int64 = 1
|
||||
sqlStore := db.InitTestDB(t)
|
||||
quotaService := quotatest.New(false, nil)
|
||||
dashboardStore, err := ProvideDashboardStore(sqlStore, sqlStore.Cfg, testFeatureToggles, tagimpl.ProvideService(sqlStore, sqlStore.Cfg), quotaService)
|
||||
require.NoError(t, err)
|
||||
folder := insertTestDashboard(t, dashboardStore, "TEST", orgId, 0, true, "prod")
|
||||
dash := insertTestDashboard(t, dashboardStore, "Very Unique Name", orgId, folder.ID, false, "prod")
|
||||
|
||||
t.Run("should return folder by ID", func(t *testing.T) {
|
||||
d, err := dashboardStore.GetFolderByID(context.Background(), orgId, folder.ID)
|
||||
require.Equal(t, folder.ID, d.ID)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
t.Run("should not find dashboard", func(t *testing.T) {
|
||||
d, err := dashboardStore.GetFolderByID(context.Background(), orgId, dash.ID)
|
||||
require.Nil(t, d)
|
||||
require.ErrorIs(t, err, dashboards.ErrFolderNotFound)
|
||||
})
|
||||
t.Run("should search in organization", func(t *testing.T) {
|
||||
d, err := dashboardStore.GetFolderByID(context.Background(), orgId+1, folder.ID)
|
||||
require.Nil(t, d)
|
||||
require.ErrorIs(t, err, dashboards.ErrFolderNotFound)
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user