Skip to content

Commit f122082

Browse files
committed
add test for #136
1 parent 7776499 commit f122082

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

cmd/report_test.go

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,29 @@ func TestRunLeftRightReport_Success(t *testing.T) {
9595
assert.Equal(t, 16, report.Summary["paths"].Breaking)
9696
}
9797

98+
func TestRunLeftRightReport_SummaryIncludesDocumentLevelOpenAPIChanges(t *testing.T) {
99+
dir := t.TempDir()
100+
101+
left := "openapi: 3.0.0\ninfo:\n title: test\n version: 1.0.0\npaths: {}\n"
102+
right := "openapi: 3.1.0\ninfo:\n title: test\n version: 2.0.0\npaths: {}\n"
103+
104+
leftPath := filepath.Join(dir, "left.yaml")
105+
rightPath := filepath.Join(dir, "right.yaml")
106+
require.NoError(t, os.WriteFile(leftPath, []byte(left), 0o644))
107+
require.NoError(t, os.WriteFile(rightPath, []byte(right), 0o644))
108+
109+
report, err := runLeftRightReport(leftPath, rightPath, summaryOpts{noColor: true}, nil)
110+
111+
require.NoError(t, err)
112+
require.NotNil(t, report)
113+
require.Contains(t, report.Summary, "openapi")
114+
require.Contains(t, report.Summary, "info")
115+
assert.Equal(t, 1, report.Summary["openapi"].Total)
116+
assert.Equal(t, 1, report.Summary["openapi"].Breaking)
117+
assert.Equal(t, 1, report.Summary["info"].Total)
118+
assert.Equal(t, 0, report.Summary["info"].Breaking)
119+
}
120+
98121
func TestRunLeftRightReport_OmitsCommitDetailsInJSON(t *testing.T) {
99122
report, err := runLeftRightReport(
100123
"../sample-specs/petstorev3-original.json",

0 commit comments

Comments
 (0)