Dashboard Migrations: V28 singlestat panel and deprecated variable properties (#108416)
Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com>
This commit is contained in:
co-authored by
Ivan Ortega
parent
3dcda77462
commit
5ad751ea28
@@ -23,7 +23,7 @@ func TestMigrate(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
// Use the same datasource provider as the frontend test to ensure consistency
|
||||
migration.Initialize(testutil.GetTestProvider())
|
||||
migration.Initialize(testutil.GetTestDataSourceProvider(), testutil.GetTestPanelProvider())
|
||||
|
||||
t.Run("minimum version check", func(t *testing.T) {
|
||||
err := migration.Migrate(map[string]interface{}{
|
||||
@@ -61,12 +61,12 @@ func TestMigrate(t *testing.T) {
|
||||
|
||||
testName := fmt.Sprintf("%s v%d to v%d", f.Name(), inputVersion, schemaversion.LATEST_VERSION)
|
||||
t.Run(testName, func(t *testing.T) {
|
||||
testMigration(t, inputDash, f.Name(), inputVersion, schemaversion.LATEST_VERSION)
|
||||
testMigration(t, inputDash, f.Name(), schemaversion.LATEST_VERSION)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func testMigration(t *testing.T, dash map[string]interface{}, inputFileName string, inputVersion, targetVersion int) {
|
||||
func testMigration(t *testing.T, dash map[string]interface{}, inputFileName string, targetVersion int) {
|
||||
t.Helper()
|
||||
require.NoError(t, migration.Migrate(dash, targetVersion), "%d migration failed", targetVersion)
|
||||
|
||||
@@ -74,11 +74,9 @@ func testMigration(t *testing.T, dash map[string]interface{}, inputFileName stri
|
||||
outBytes, err := json.MarshalIndent(dash, "", " ")
|
||||
require.NoError(t, err, "failed to marshal migrated dashboard")
|
||||
|
||||
if _, err := os.Stat(outPath); os.IsNotExist(err) {
|
||||
err = os.WriteFile(outPath, outBytes, 0644)
|
||||
require.NoError(t, err, "failed to write new output file", outPath)
|
||||
return
|
||||
}
|
||||
// Overwrite the output file with the new output
|
||||
err = os.WriteFile(outPath, outBytes, 0644)
|
||||
require.NoError(t, err, "failed to write output file", outPath)
|
||||
|
||||
// We can ignore gosec G304 here since it's a test
|
||||
// nolint:gosec
|
||||
|
||||
Reference in New Issue
Block a user