From 1f0ff194716ccb986950afc7887d22563a1cdc01 Mon Sep 17 00:00:00 2001 From: Todd Treece <360020+toddtreece@users.noreply.github.com> Date: Tue, 4 Feb 2025 09:16:03 -0500 Subject: [PATCH] Dashboards: Fix schemaVersion test order (#100016) --- pkg/apis/dashboard/migration/migrate_test.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/pkg/apis/dashboard/migration/migrate_test.go b/pkg/apis/dashboard/migration/migrate_test.go index af6a1305ea3..a24baa993ee 100644 --- a/pkg/apis/dashboard/migration/migrate_test.go +++ b/pkg/apis/dashboard/migration/migrate_test.go @@ -3,7 +3,6 @@ package migration_test import ( "encoding/json" "fmt" - "io/fs" "os" "path/filepath" "strconv" @@ -51,18 +50,17 @@ func TestMigrate(t *testing.T) { require.JSONEq(t, string(expectedDash), string(outBytes), "%s input check did not match", f.Name()) }) - for targetVersion := range schemaversion.Migrations { + for targetVersion := inputVersion + 1; targetVersion <= schemaversion.LATEST_VERSION; targetVersion++ { testName := fmt.Sprintf("%s v%d to v%d", name, inputVersion, targetVersion) t.Run(testName, func(t *testing.T) { - testMigration(t, f, targetVersion) + testMigration(t, inputDash, name, inputVersion, targetVersion) }) } } } -func testMigration(t *testing.T, file fs.DirEntry, targetVersion int) { +func testMigration(t *testing.T, dash map[string]interface{}, name string, inputVersion, targetVersion int) { t.Helper() - dash, inputVersion, name := load(t, filepath.Join(INPUT_DIR, file.Name())) require.NoError(t, migration.Migrate(dash, targetVersion), "%d migration failed", targetVersion) outPath := filepath.Join(OUTPUT_DIR, fmt.Sprintf("%d.%s.%d.json", inputVersion, name, targetVersion))