Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit efedab0

Browse files
committed
chore(cli/clitest): nicer diff
1 parent f805f3a commit efedab0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

cli/clitest/golden.go

+4-5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"strings"
1212
"testing"
1313

14+
"github.com/google/go-cmp/cmp"
1415
"github.com/google/uuid"
1516
"github.com/stretchr/testify/require"
1617

@@ -117,11 +118,9 @@ func TestGoldenFile(t *testing.T, fileName string, actual []byte, replacements m
117118
require.NoError(t, err, "read golden file, run \"make gen/golden-files\" and commit the changes")
118119

119120
expected = normalizeGoldenFile(t, expected)
120-
require.Equal(
121-
t, string(expected), string(actual),
122-
"golden file mismatch: %s, run \"make gen/golden-files\", verify and commit the changes",
123-
goldenPath,
124-
)
121+
if diff := cmp.Diff(string(expected), string(actual)); diff != "" {
122+
t.Fatalf("golden file mismatch: %s, run \"make gen/golden-files\", verify and commit the changes", goldenPath)
123+
}
125124
}
126125

127126
// normalizeGoldenFile replaces any strings that are system or timing dependent

0 commit comments

Comments
 (0)