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:
@@ -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
|
||||
|
||||
+2
-2
@@ -148,7 +148,7 @@
|
||||
{
|
||||
"options": {
|
||||
"20": {
|
||||
"color": null,
|
||||
"color": "orange",
|
||||
"text": "test"
|
||||
}
|
||||
},
|
||||
@@ -157,7 +157,7 @@
|
||||
{
|
||||
"options": {
|
||||
"30": {
|
||||
"color": null,
|
||||
"color": "orange",
|
||||
"text": "test1"
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user