@@ -62,19 +62,46 @@ var _ = Describe("Formatter", func() {
62
62
})
63
63
})
64
64
65
- Context ("with environment overrides" , func () {
66
- BeforeEach (func () {
67
- os .Setenv ("GINKGO_CLI_COLOR_RED" , "\x1b [31m" )
68
- })
65
+ DescribeTable ("with environment overrides" ,
66
+ func (envVars map [string ]string , input , expected string ) {
67
+ for envVar , value := range envVars {
68
+ os .Setenv (envVar , value )
69
+ }
70
+ f := formatter .New (colorMode )
71
+ Ω (f .F (input )).Should (Equal (expected ))
72
+ for envVar := range envVars {
73
+ os .Unsetenv (envVar )
74
+ }
75
+ },
69
76
70
- AfterEach ( func () {
71
- os . Unsetenv ( "GINKGO_CLI_COLOR_RED" )
72
- })
77
+ Entry ( "uses default for too low codes" , map [ string ] string {
78
+ "GINKGO_CLI_COLOR_RED" : "-1" ,
79
+ }, "{{red}}hi there{{/}}" , " \x1b [38;5;9mhi there \x1b [0m" ),
73
80
74
- It ("uses the escape codes from the environment variables" , func () {
75
- Ω (f .F ("{{red}}hi there{{/}}" )).Should (Equal ("\x1b [31mhi there\x1b [0m" ))
76
- })
77
- })
81
+ Entry ("uses default for too high codes" , map [string ]string {
82
+ "GINKGO_CLI_COLOR_RED" : "256" ,
83
+ }, "{{red}}hi there{{/}}" , "\x1b [38;5;9mhi there\x1b [0m" ),
84
+
85
+ Entry ("supports literal alias for 8bit color" , map [string ]string {
86
+ "GINKGO_CLI_COLOR_RED" : "red" ,
87
+ }, "{{red}}hi there{{/}}" , "\x1b [38;5;1mhi there\x1b [0m" ),
88
+
89
+ Entry ("supports number alias for 8bit color" , map [string ]string {
90
+ "GINKGO_CLI_COLOR_RED" : "1" ,
91
+ }, "{{red}}hi there{{/}}" , "\x1b [38;5;1mhi there\x1b [0m" ),
92
+
93
+ Entry ("supports 16bit colors (bright)" , map [string ]string {
94
+ "GINKGO_CLI_COLOR_RED" : "9" ,
95
+ }, "{{red}}hi there{{/}}" , "\x1b [38;5;9mhi there\x1b [0m" ),
96
+
97
+ Entry ("supports 16bit color literal aliases (bright)" , map [string ]string {
98
+ "GINKGO_CLI_COLOR_RED" : "bright-red" ,
99
+ }, "{{red}}hi there{{/}}" , "\x1b [38;5;9mhi there\x1b [0m" ),
100
+
101
+ Entry ("supports extended 256 colors" , map [string ]string {
102
+ "GINKGO_CLI_COLOR_RED" : "16" ,
103
+ }, "{{red}}hi there{{/}}" , "\x1b [38;5;16mhi there\x1b [0m" ),
104
+ )
78
105
79
106
Describe ("NewWithNoColorBool" , func () {
80
107
Context ("when the noColor bool is true" , func () {
0 commit comments