feat: add library elements to dash service (#114016)

This commit is contained in:
Costa Alexoglou
2025-11-18 09:21:05 +01:00
committed by GitHub
parent d6e81c6334
commit faabe2e46d
12 changed files with 162 additions and 36 deletions
+15 -5
View File
@@ -29,7 +29,9 @@ const DEV_DASHBOARDS_OUTPUT_DIR = "testdata/dev-dashboards-output"
func TestMigrate(t *testing.T) {
// Reset the migration singleton and use the same datasource provider as the frontend test to ensure consistency
ResetForTesting()
Initialize(migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig))
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
leProvider := migrationtestutil.NewLibraryElementProvider()
Initialize(dsProvider, leProvider)
t.Run("minimum version check", func(t *testing.T) {
err := Migrate(context.Background(), map[string]interface{}{
@@ -45,7 +47,9 @@ func TestMigrate(t *testing.T) {
func TestMigrateSingleVersion(t *testing.T) {
// Use the same datasource provider as the frontend test to ensure consistency
Initialize(migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig))
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
leProvider := migrationtestutil.NewLibraryElementProvider()
Initialize(dsProvider, leProvider)
runSingleVersionMigrationTests(t, SINGLE_VERSION_OUTPUT_DIR)
}
@@ -212,7 +216,9 @@ func loadDashboard(t *testing.T, path string) map[string]interface{} {
// TestSchemaMigrationMetrics tests that schema migration metrics are recorded correctly
func TestSchemaMigrationMetrics(t *testing.T) {
// Initialize migration with test providers
Initialize(migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig))
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
leProvider := migrationtestutil.NewLibraryElementProvider()
Initialize(dsProvider, leProvider)
// Create a test registry for metrics
registry := prometheus.NewRegistry()
@@ -296,7 +302,9 @@ func TestSchemaMigrationMetrics(t *testing.T) {
// TestSchemaMigrationLogging tests that schema migration logging works correctly
func TestSchemaMigrationLogging(t *testing.T) {
Initialize(migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig))
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.StandardTestConfig)
leProvider := migrationtestutil.NewLibraryElementProvider()
Initialize(dsProvider, leProvider)
tests := []struct {
name string
@@ -413,7 +421,9 @@ func TestMigrateDevDashboards(t *testing.T) {
// Reset the migration singleton and use the dev dashboard datasource provider
// to match the frontend devDashboardDataSources configuration
ResetForTesting()
Initialize(migrationtestutil.NewDataSourceProvider(migrationtestutil.DevDashboardConfig))
dsProvider := migrationtestutil.NewDataSourceProvider(migrationtestutil.DevDashboardConfig)
leProvider := migrationtestutil.NewLibraryElementProvider()
Initialize(dsProvider, leProvider)
runDevDashboardMigrationTests(t, schemaversion.LATEST_VERSION, DEV_DASHBOARDS_OUTPUT_DIR)
}