diff --git a/pkg/clog/clog.go b/pkg/clog/clog.go index 0a523e1f..ebdce686 100644 --- a/pkg/clog/clog.go +++ b/pkg/clog/clog.go @@ -35,12 +35,11 @@ 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", + fmt.Fprintf(&str, "%s: %s\r\n", color.New(m.Color).Sprint(m.Level), - color.New(color.Bold).Sprint(m.Header)), - ) + 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)) + fmt.Fprintf(&str, " %s %s\r\n", color.New(m.Color).Sprint("|"), line) } return str.String() } diff --git a/pkg/clog/clog_test.go b/pkg/clog/clog_test.go index 51eab07e..6967eb3c 100644 --- a/pkg/clog/clog_test.go +++ b/pkg/clog/clog_test.go @@ -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) { @@ -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) { @@ -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)) } }) @@ -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), ) }) diff --git a/pkg/clog/errgroup_test.go b/pkg/clog/errgroup_test.go index b632921d..0d209d81 100644 --- a/pkg/clog/errgroup_test.go +++ b/pkg/clog/errgroup_test.go @@ -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")) }) }