Only add newline to file when needed

This commit is contained in:
Dan Jones 2024-03-09 15:38:34 -06:00
commit 5b8e4696ea
4 changed files with 82 additions and 5 deletions

View file

@ -90,13 +90,13 @@ func getEntryMarshalTestRunner(title string, date time.Time, fields []Meta, firs
if first == "" {
return
}
os := string(o)
if len(lines) == 0 {
assert.Equal(t, "\n"+first, string(o))
assert.Equal(t, first, os)
return
}
os := string(o)
assert.Regexp(t, "^\n"+first, os)
assert.Regexp(t, first, os)
for _, line := range lines {
assert.Regexp(t, "(?m)^"+line, os)
}