Skip to content

Commit 5d76046

Browse files
adding back ANSI strip
1 parent 12b872c commit 5d76046

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

cli_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ package main
33
import (
44
"bytes"
55
"os"
6+
"regexp"
67
"testing"
78
)
89

10+
var ansiRegex = regexp.MustCompile(`\x1b\[[0-9;]*m`)
11+
912
func captureOutput(f func()) string {
1013
var buf bytes.Buffer
1114
stdout := os.Stdout
@@ -21,6 +24,10 @@ func captureOutput(f func()) string {
2124
return buf.String()
2225
}
2326

27+
func stripANSI(input string) string {
28+
return ansiRegex.ReplaceAllString(input, "")
29+
}
30+
2431
func TestRunCLI(t *testing.T) {
2532
tests := []struct {
2633
name string
@@ -118,6 +125,8 @@ func TestRunCLI(t *testing.T) {
118125
}
119126
})
120127

128+
output = stripANSI(output)
129+
121130
if !bytes.Contains([]byte(output), []byte(tt.expectedOutput)) {
122131
t.Errorf("Expected output to contain %q, got %q", tt.expectedOutput, output)
123132
}

0 commit comments

Comments
 (0)