Schema V2: Snapshot testing for migrations should fail when output doesn't match (#109278)

* Schema v2: Snapshot testing for migration fails when doesn't match

* Update snapshot
This commit is contained in:
Ivan Ortega Alba
2025-08-06 19:50:21 +00:00
committed by GitHub
parent 2bf9aea8ef
commit d1cff535d2
2 changed files with 7 additions and 5 deletions
+5 -3
View File
@@ -74,9 +74,11 @@ 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")
// Overwrite the output file with the new output
err = os.WriteFile(outPath, outBytes, 0644)
require.NoError(t, err, "failed to write output file", outPath)
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
}
// We can ignore gosec G304 here since it's a test
// nolint:gosec
@@ -148,7 +148,7 @@
{
"options": {
"20": {
"color": null,
"color": "orange",
"text": "test"
}
},
@@ -157,7 +157,7 @@
{
"options": {
"30": {
"color": null,
"color": "orange",
"text": "test1"
}
},