Skip to content

Commit

Permalink
Add Test_noColorIsSet
Browse files Browse the repository at this point in the history
  • Loading branch information
pellared committed Nov 13, 2022
1 parent 8e3ccd4 commit b06fcbf
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions color_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit b06fcbf

Please sign in to comment.