Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

chore: Add line returns to clog output #414

Merged
merged 2 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
chore: Add line returns to clog output
  • Loading branch information
kylecarbs committed Aug 11, 2021
commit 76e4bde1c75510e5c51d057daf89e80da48e883a
4 changes: 2 additions & 2 deletions pkg/clog/clog.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ type CLIError struct {
// String formats the CLI message for consumption by a human.
func (m CLIMessage) String() string {
var str strings.Builder
str.WriteString(fmt.Sprintf("%s: %s\n",
str.WriteString(fmt.Sprintf("%s: %s\r\n",
color.New(m.Color).Sprint(m.Level),
color.New(color.Bold).Sprint(m.Header)),
)
for _, line := range m.Lines {
str.WriteString(fmt.Sprintf(" %s %s\n", color.New(m.Color).Sprint("|"), line))
str.WriteString(fmt.Sprintf(" %s %s\r\n", color.New(m.Color).Sprint("|"), line))
}
return str.String()
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/clog/clog_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestError(t *testing.T) {
output, err := ioutil.ReadAll(&buf)
assert.Success(t, "read all stderr output", err)

assert.Equal(t, "output is as expected", "error: fake error\n\n", string(output))
assert.Equal(t, "output is as expected", "error: fake error\r\n\n", string(output))
})

t.Run("plain-error", func(t *testing.T) {
Expand All @@ -41,7 +41,7 @@ func TestError(t *testing.T) {
output, err := ioutil.ReadAll(&buf)
assert.Success(t, "read all stderr output", err)

assert.Equal(t, "output is as expected", "fatal: wrap 1: base error\n\n", string(output))
assert.Equal(t, "output is as expected", "fatal: wrap 1: base error\r\n\n", string(output))
})

t.Run("message", func(t *testing.T) {
Expand All @@ -58,7 +58,7 @@ func TestError(t *testing.T) {
output, err := ioutil.ReadAll(&buf)
assert.Success(t, "read all stderr output", err)

assert.Equal(t, "output is as expected", f.level+": testing\n | hint: maybe do \"this\"\n | \n | cause: what happened was \"this\"\n", string(output))
assert.Equal(t, "output is as expected", f.level+": testing\r\n | hint: maybe do \"this\"\r\n | \r\n | cause: what happened was \"this\"\r\n", string(output))
}
})

Expand All @@ -78,7 +78,7 @@ func TestError(t *testing.T) {

assert.Equal(t,
"output is as expected",
"error: fake header\n | next line\n | \n | tip: content of fake tip\n\n",
"error: fake header\r\n | next line\r\n | \r\n | tip: content of fake tip\r\n\n",
string(output),
)
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/clog/errgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func TestErrGroup(t *testing.T) {

err := egroup.Wait()
assert.ErrorContains(t, "error group wait", err, "2 failures emitted")
assert.True(t, "log buf contains", strings.Contains(buf.String(), "fatal: whoops\n\n"))
assert.True(t, "log buf contains", strings.Contains(buf.String(), "error: rich error\n | second line\n\n"))
assert.True(t, "log buf contains", strings.Contains(buf.String(), "fatal: whoops\r\n\n"))
assert.True(t, "log buf contains", strings.Contains(buf.String(), "error: rich error\r\n | second line\r\n\n"))
})
}