1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00
Files
stackexchange-dnscontrol/pkg/notifications/notifications_test.go
2023-08-29 13:24:09 -04:00

26 lines
633 B
Go

package notifications
import "testing"
func Test_stripAnsiColorsValid(t *testing.T) {
coloredStr := "\x1b[0133myellow\x1b[0m" // 33 == yellow
nonColoredStr := "yellow"
s := stripAnsiColors(coloredStr)
if s != nonColoredStr {
t.Errorf("stripAnsiColors() stripped %q different from %q", coloredStr, nonColoredStr)
}
}
func Test_stripAnsiColorsInvalid(t *testing.T) {
coloredStr := "\x1b[01AAmyellow\x1b[0m" // AA not a real color
nonColoredStr := "yellow"
s := stripAnsiColors(coloredStr)
if s == nonColoredStr {
t.Errorf("stripAnsiColors() stripped %q should be different from %q", coloredStr, nonColoredStr)
}
}