Skip to content

Commit

Permalink
Fixed empty suggestions section.
Browse files Browse the repository at this point in the history
  • Loading branch information
jmalloc committed Aug 22, 2024
1 parent b8e4bce commit db5a187
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ The format is based on [Keep a Changelog], and this project adheres to
[keep a changelog]: https://keepachangelog.com/en/1.0.0/
[semantic versioning]: https://semver.org/spec/v2.0.0.html

## Unreleased

### Fixed

- Fixed issue that caused an empty `SUGGESTIONS` section to be printed on test
reports in some circumstances.

## [0.17.0] - 2024-08-21

### Added
Expand Down
15 changes: 11 additions & 4 deletions report.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,14 @@ func (r *Report) WriteTo(next io.Writer) (_ int64, err error) {

must.WriteByte(w, '\n')

if len(r.Sections) != 0 || r.Explanation != "" {
var sections []*ReportSection
for _, s := range r.Sections {
if s.Content.Len() != 0 {
sections = append(sections, s)
}
}

if len(sections) != 0 || r.Explanation != "" {
must.WriteByte(w, '\n')

iw := indent.NewIndenter(w, sectionsIndent)
Expand All @@ -134,12 +141,12 @@ func (r *Report) WriteTo(next io.Writer) (_ int64, err error) {

must.WriteByte(iw, '\n')

if len(r.Sections) != 0 {
if len(sections) != 0 {
must.WriteByte(iw, '\n')
}
}

for i, s := range r.Sections {
for i, s := range sections {
must.WriteString(iw, strings.ToUpper(s.Title))
must.WriteString(iw, "\n")

Expand All @@ -153,7 +160,7 @@ func (r *Report) WriteTo(next io.Writer) (_ int64, err error) {

must.WriteByte(iw, '\n')

if i < len(r.Sections)-1 {
if i < len(sections)-1 {
must.WriteByte(iw, '\n')
}
}
Expand Down

0 comments on commit db5a187

Please sign in to comment.