Skip to content

Commit bd6ebbd

Browse files
committed
Fix tests using testdata with trailing newlines by slicing off whitespace
1 parent b55a6c4 commit bd6ebbd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

internal/mbtest/helper.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,11 @@ func Testdata(t *testing.T, relativePath string) []byte {
2222
return b
2323
}
2424

25-
// AssertTestdata gets testdata and asserts it equals actual.
25+
// AssertTestdata gets testdata and asserts it equals actual. We start by
26+
// slicing off all leading and trailing white space, as defined by Unicode.
2627
func AssertTestdata(t *testing.T, relativePath string, actual []byte) {
27-
expected := Testdata(t, relativePath)
28+
expected := bytes.TrimSpace(Testdata(t, relativePath))
29+
actual = bytes.TrimSpace(actual)
2830

2931
if !bytes.Equal(expected, actual) {
3032
t.Fatalf("expected %s, got %s", expected, actual)

0 commit comments

Comments
 (0)