Skip to content

Commit 66907ba

Browse files
committed
fix diff tests
1 parent bb3d3dd commit 66907ba

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

diff/spec_analyser_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func TestDiffForVariousCombinations(t *testing.T) {
5656
out, err, warn := diffs.ReportAllDiffs(false)
5757
require.NoError(t, err)
5858

59-
if !cmdtest.AssertReadersContent(t, true, tc.expectedLines, out) {
59+
if !cmdtest.AssertReadersContent(t, false, tc.expectedLines, out) {
6060
t.Logf("unexpected content for fixture %q[%d] (file: %s)", tc.name, i, tc.expectedFile)
6161
}
6262

diff/spec_difference.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,13 +138,16 @@ func (sd *SpecDifferences) ReportCompatibility() (io.Reader, error, error) {
138138
var out bytes.Buffer
139139
breakingCount := sd.BreakingChangeCount()
140140
if breakingCount > 0 {
141-
fmt.Fprintln(&out, "\nBREAKING CHANGES:\n=================")
141+
if len(*sd) != breakingCount {
142+
fmt.Fprintln(&out, "")
143+
}
144+
fmt.Fprintln(&out, "BREAKING CHANGES:\n=================")
142145
_, _ = out.ReadFrom(sd.reportChanges(Breaking))
143146
msg := fmt.Sprintf("compatibility test FAILED: %d breaking changes detected", breakingCount)
144147
fmt.Fprintln(&out, msg)
145148
return &out, nil, errors.New(msg)
146149
}
147-
fmt.Fprintf(&out, "compatibility test OK. No breaking changes identified.")
150+
fmt.Fprintf(&out, "compatibility test OK. No breaking changes identified.\n")
148151
return &out, nil, nil
149152
}
150153

@@ -180,7 +183,7 @@ func (sd SpecDifferences) ReportAllDiffs(fmtJSON bool) (io.Reader, error, error)
180183
}
181184
numDiffs := len(sd)
182185
if numDiffs == 0 {
183-
return bytes.NewBuffer([]byte("No changes identified")), nil, nil
186+
return bytes.NewBuffer([]byte("No changes identified\n")), nil, nil
184187
}
185188

186189
var out bytes.Buffer

0 commit comments

Comments
 (0)