mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboards: Fix schemaVersion test order (#100016)
This commit is contained in:
@@ -3,7 +3,6 @@ package migration_test
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strconv"
|
"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())
|
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)
|
testName := fmt.Sprintf("%s v%d to v%d", name, inputVersion, targetVersion)
|
||||||
t.Run(testName, func(t *testing.T) {
|
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()
|
t.Helper()
|
||||||
dash, inputVersion, name := load(t, filepath.Join(INPUT_DIR, file.Name()))
|
|
||||||
require.NoError(t, migration.Migrate(dash, targetVersion), "%d migration failed", targetVersion)
|
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))
|
outPath := filepath.Join(OUTPUT_DIR, fmt.Sprintf("%d.%s.%d.json", inputVersion, name, targetVersion))
|
||||||
|
|||||||
Reference in New Issue
Block a user