1
0
mirror of https://github.com/fatih/color.git synced 2024-11-24 08:02:14 +02:00

Add Test_noColorIsSet

This commit is contained in:
Robert Pająk 2022-11-13 11:13:42 +01:00
parent 8e3ccd4921
commit b06fcbf502
No known key found for this signature in database
GPG Key ID: 7980FE28BD616F02

View File

@ -199,6 +199,41 @@ func TestNoColor_Env(t *testing.T) {
}
}
func Test_noColorIsSet(t *testing.T) {
tests := []struct {
name string
act func()
want bool
}{
{
name: "default",
act: func() {},
want: false,
},
{
name: "NO_COLOR=1",
act: func() { os.Setenv("NO_COLOR", "1") },
want: true,
},
{
name: "NO_COLOR=",
act: func() { os.Setenv("NO_COLOR", "") },
want: false,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Cleanup(func() {
os.Unsetenv("NO_COLOR")
})
tt.act()
if got := noColorIsSet(); got != tt.want {
t.Errorf("noColorIsSet() = %v, want %v", got, tt.want)
}
})
}
}
func TestColorVisual(t *testing.T) {
// First Visual Test
Output = colorable.NewColorableStdout()