Skip to content

Commit de7c73c

Browse files
committed
Fix broken test
Trying to test the actual terminal output doesn't always work across different platforms.
1 parent d5c77f0 commit de7c73c

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

pkg/renderer/printer_log.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ func (pl *PrinterLog) Write(b []byte) (n int, err error) {
1717
str := pl.Prefix.WithShowLineNumber(false).Sprint(string(b))
1818
pterm.Println(str)
1919

20-
return len(str), nil
20+
return len(b), nil
2121
}

pkg/renderer/printer_log_test.go

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,14 @@ import (
66
"github.com/pterm/pterm"
77
)
88

9-
func TestWriteDefaultPrefix(t *testing.T) {
9+
func TestWrite(t *testing.T) {
1010
pterm.DisableOutput()
1111

1212
pl := PrinterLog{}
1313
b := []byte("foobar")
1414
i, _ := pl.Write(b)
1515

16-
if i != 34 {
17-
t.Errorf("Expected str len %d, got %d", 34, i)
18-
}
19-
}
20-
21-
func TestWriteErrorPrefix(t *testing.T) {
22-
pterm.DisableOutput()
23-
24-
pl := PrinterLog{Prefix: pterm.Error}
25-
b := []byte("foobar")
26-
i, _ := pl.Write(b)
27-
28-
if i != 38 {
29-
t.Errorf("Expected str len %d, got %d", 38, i)
16+
if i != len(b) {
17+
t.Errorf("Expected str len %d, got %d", len(b), i)
3018
}
3119
}

0 commit comments

Comments
 (0)