refactor: simplify code

main
sundowndev 2021-07-21 17:00:53 +02:00
parent 8db91837be
commit d1436cdac3
1 changed files with 6 additions and 4 deletions

View File

@ -37,6 +37,12 @@ func ReadFile(p string, name string) []byte {
func WriteFile(p string, content []byte, name string) {
output := content
// Avoid creating golden files for empty results
if name == ResultsFilename && string(output) == "[]" {
return
}
p = path.Join(GoldenFilePath, p)
if err := os.MkdirAll(p, os.ModePerm); err != nil {
panic(err)
@ -50,10 +56,6 @@ func WriteFile(p string, content []byte, name string) {
logrus.Error(err)
}
if name == ResultsFilename && string(output) == "[]" {
return
}
if err := ioutil.WriteFile(fmt.Sprintf("%s%c%s", p, os.PathSeparator, sanitizeName(name)), output, os.ModePerm); err != nil {
panic(err)
}