@@ -24,36 +24,7 @@ import (
2424 "github.com/stretchr/testify/assert"
2525)
2626
27- func Test_Commandf (t * testing.T ) {
28- tests := map [string ]struct {
29- process string
30- command string
31- isPrimary bool
32- }{
33- "primary command contains process and command" : {
34- process : "renamed-slack-command" ,
35- command : "feedback" ,
36- isPrimary : true ,
37- },
38- "secondary command contains process and command" : {
39- process : "a-renamed-slack-cli" ,
40- command : "feedback" ,
41- isPrimary : false ,
42- },
43- }
44- for name , tc := range tests {
45- t .Run (name , func (t * testing.T ) {
46- processTemp := os .Args [0 ]
47- os .Args [0 ] = tc .process
48- defer func () { os .Args [0 ] = processTemp }()
49-
50- formatted := Commandf (tc .command , tc .isPrimary )
51- assert .Contains (t , formatted , tc .process + " " + tc .command )
52- })
53- }
54- }
55-
56- func Test_getKeyLength (t * testing.T ) {
27+ func TestGetKeyLength (t * testing.T ) {
5728 tests := map [string ]struct {
5829 keys map [string ]string
5930 expected int
@@ -82,13 +53,7 @@ func Test_getKeyLength(t *testing.T) {
8253 }
8354}
8455
85- func TestIndent (t * testing.T ) {
86- text := "a few spaces are expected at the start of this line, but no other changes"
87- indented := Indent (text )
88- assert .Contains (t , indented , text )
89- }
90-
91- func Test_Sectionf (t * testing.T ) {
56+ func TestSectionf (t * testing.T ) {
9257 tests := map [string ]struct {
9358 section TextSection
9459 expected string
@@ -117,7 +82,7 @@ func TestSectionHeaderfEmpty(t *testing.T) {
11782 assert .Equal (t , "" , SectionHeaderf ("tada" , "" ))
11883}
11984
120- func Test_SectionSecondaryf (t * testing.T ) {
85+ func TestSectionSecondaryf (t * testing.T ) {
12186 tests := map [string ]struct {
12287 format string
12388 args []interface {}
@@ -165,29 +130,41 @@ func Test_SectionSecondaryf(t *testing.T) {
165130 }
166131}
167132
168- func TestSurveyIcons (t * testing.T ) {
133+ func TestCommandf (t * testing.T ) {
169134 tests := map [string ]struct {
170- styleEnabled bool
135+ process string
136+ command string
137+ isPrimary bool
171138 }{
172- "styles are not enabled" : {
173- styleEnabled : false ,
139+ "primary command contains process and command" : {
140+ process : "renamed-slack-command" ,
141+ command : "feedback" ,
142+ isPrimary : true ,
174143 },
175- "styles are enabled" : {
176- styleEnabled : true ,
144+ "secondary command contains process and command" : {
145+ process : "a-renamed-slack-cli" ,
146+ command : "feedback" ,
147+ isPrimary : false ,
177148 },
178149 }
179-
180150 for name , tc := range tests {
181151 t .Run (name , func (t * testing.T ) {
182- core .DisableColor = false
183- isStyleEnabled = tc .styleEnabled
152+ processTemp := os .Args [0 ]
153+ os .Args [0 ] = tc .process
154+ defer func () { os .Args [0 ] = processTemp }()
184155
185- _ = SurveyIcons ( )
186- assert .NotEqual (t , tc .styleEnabled , core . DisableColor )
156+ formatted := Commandf ( tc . command , tc . isPrimary )
157+ assert .Contains (t , formatted , tc .process + " " + tc . command )
187158 })
188159 }
189160}
190161
162+ func TestIndent (t * testing.T ) {
163+ text := "a few spaces are expected at the start of this line, but no other changes"
164+ indented := Indent (text )
165+ assert .Contains (t , indented , text )
166+ }
167+
191168func TestTracef (t * testing.T ) {
192169 tests := map [string ]struct {
193170 traceID string
@@ -222,6 +199,29 @@ func TestTracef(t *testing.T) {
222199 }
223200}
224201
202+ func TestSurveyIcons (t * testing.T ) {
203+ tests := map [string ]struct {
204+ styleEnabled bool
205+ }{
206+ "styles are not enabled" : {
207+ styleEnabled : false ,
208+ },
209+ "styles are enabled" : {
210+ styleEnabled : true ,
211+ },
212+ }
213+
214+ for name , tc := range tests {
215+ t .Run (name , func (t * testing.T ) {
216+ core .DisableColor = false
217+ isStyleEnabled = tc .styleEnabled
218+
219+ _ = SurveyIcons ()
220+ assert .NotEqual (t , tc .styleEnabled , core .DisableColor )
221+ })
222+ }
223+ }
224+
225225/*
226226* Example commands
227227 */
0 commit comments