File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change @@ -199,6 +199,41 @@ func TestNoColor_Env(t *testing.T) {
199199 }
200200}
201201
202+ func Test_noColorIsSet (t * testing.T ) {
203+ tests := []struct {
204+ name string
205+ act func ()
206+ want bool
207+ }{
208+ {
209+ name : "default" ,
210+ act : func () {},
211+ want : false ,
212+ },
213+ {
214+ name : "NO_COLOR=1" ,
215+ act : func () { os .Setenv ("NO_COLOR" , "1" ) },
216+ want : true ,
217+ },
218+ {
219+ name : "NO_COLOR=" ,
220+ act : func () { os .Setenv ("NO_COLOR" , "" ) },
221+ want : false ,
222+ },
223+ }
224+ for _ , tt := range tests {
225+ t .Run (tt .name , func (t * testing.T ) {
226+ t .Cleanup (func () {
227+ os .Unsetenv ("NO_COLOR" )
228+ })
229+ tt .act ()
230+ if got := noColorIsSet (); got != tt .want {
231+ t .Errorf ("noColorIsSet() = %v, want %v" , got , tt .want )
232+ }
233+ })
234+ }
235+ }
236+
202237func TestColorVisual (t * testing.T ) {
203238 // First Visual Test
204239 Output = colorable .NewColorableStdout ()
You can’t perform that action at this time.
0 commit comments