Fix error checking so that if /tmp/test-goldens/ exists, then we don't error out

This commit is contained in:
David Dworken 2023-12-03 16:48:45 -08:00
parent f88e1d5b3b
commit acdcd9569a
No known key found for this signature in database

View File

@ -370,7 +370,7 @@ func CompareGoldens(t testing.TB, out, goldenName string) {
} }
} }
if diff := cmp.Diff(string(expected), out); diff != "" { if diff := cmp.Diff(string(expected), out); diff != "" {
if err := os.Mkdir("/tmp/test-goldens", os.ModePerm); err != nil { if err := os.Mkdir("/tmp/test-goldens", os.ModePerm); err != nil && !os.IsExist(err) {
log.Fatal(err) log.Fatal(err)
} }
require.NoError(t, os.WriteFile(path.Join("/tmp/test-goldens", goldenName), []byte(out), 0644)) require.NoError(t, os.WriteFile(path.Join("/tmp/test-goldens", goldenName), []byte(out), 0644))