@@ -2,6 +2,7 @@ package text
2
2
3
3
import (
4
4
"fmt"
5
+ "os"
5
6
"testing"
6
7
7
8
"github.com/stretchr/testify/assert"
@@ -24,6 +25,24 @@ func TestColor_EnableAndDisable(t *testing.T) {
24
25
assert .Equal (t , "\x1b [31mtest\x1b [0m" , FgRed .Sprint ("test" ))
25
26
}
26
27
28
+ func TestColor_areColorsOnInTheEnv (t * testing.T ) {
29
+ _ = os .Setenv ("FORCE_COLOR" , "0" )
30
+ _ = os .Setenv ("NO_COLOR" , "0" )
31
+ assert .True (t , areColorsOnInTheEnv ())
32
+
33
+ _ = os .Setenv ("FORCE_COLOR" , "0" )
34
+ _ = os .Setenv ("NO_COLOR" , "1" )
35
+ assert .False (t , areColorsOnInTheEnv ())
36
+
37
+ _ = os .Setenv ("FORCE_COLOR" , "1" )
38
+ _ = os .Setenv ("NO_COLOR" , "0" )
39
+ assert .True (t , areColorsOnInTheEnv ())
40
+
41
+ _ = os .Setenv ("FORCE_COLOR" , "1" )
42
+ _ = os .Setenv ("NO_COLOR" , "1" )
43
+ assert .True (t , areColorsOnInTheEnv ())
44
+ }
45
+
27
46
func ExampleColor_EscapeSeq () {
28
47
fmt .Printf ("Black Background: %#v\n " , BgBlack .EscapeSeq ())
29
48
fmt .Printf ("Black Foreground: %#v\n " , FgBlack .EscapeSeq ())
0 commit comments