Skip to content

Commit 7f291df

Browse files
committed
tidy: condense test file curly brackets and move some comments
1 parent d4c0af2 commit 7f291df

3 files changed

Lines changed: 96 additions & 164 deletions

File tree

builder_test.go

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ func TestBuilder(t *testing.T) {
1818
func() { c := NewCmd("a"); c.Parse() },
1919
},
2020
expPanicVals: []any{nil, nil},
21-
},
22-
{
21+
}, {
2322
name: "mixing positional args and subcommands",
2423
builds: []func(){
2524
func() {
@@ -37,8 +36,7 @@ func TestBuilder(t *testing.T) {
3736
errMixingPosArgsAndSubcmds,
3837
errMixingPosArgsAndSubcmds,
3938
},
40-
},
41-
{
39+
}, {
4240
name: "empty command name",
4341
builds: []func(){
4442
func() { NewCmd("") },
@@ -48,8 +46,7 @@ func TestBuilder(t *testing.T) {
4846
errEmptyCmdName,
4947
errEmptyCmdName,
5048
},
51-
},
52-
{
49+
}, {
5350
name: "command name with whitespace",
5451
builds: []func(){
5552
func() { NewCmd(" ") },
@@ -61,8 +58,7 @@ func TestBuilder(t *testing.T) {
6158
"invalid command name 'a b': cannot contain whitespace",
6259
"invalid command name 'c\td': cannot contain whitespace",
6360
},
64-
},
65-
{
61+
}, {
6662
name: "empty input ids",
6763
builds: []func(){
6864
func() { NewCmd("root").Opt(NewOpt("")) },
@@ -72,13 +68,11 @@ func TestBuilder(t *testing.T) {
7268
errEmptyInputID,
7369
errEmptyInputID,
7470
},
75-
},
76-
{
71+
}, {
7772
name: "empty option names",
7873
builds: []func(){func() { NewCmd("root").Opt(NewArg("a1")) }},
7974
expPanicVals: []any{errEmptyOptNames},
80-
},
81-
{
75+
}, {
8276
name: "duplicate option ids",
8377
builds: []func(){
8478
func() {
@@ -107,8 +101,7 @@ func TestBuilder(t *testing.T) {
107101
"command 'root one' contains duplicate input ids 'o1'",
108102
"command 'root' contains duplicate input ids 'a1'",
109103
},
110-
},
111-
{
104+
}, {
112105
name: "duplicate option short names",
113106
builds: []func(){
114107
func() {
@@ -135,8 +128,7 @@ func TestBuilder(t *testing.T) {
135128
"command 'root' contains duplicate option short name 'a'",
136129
"command 'root' contains duplicate option short name 'b'",
137130
},
138-
},
139-
{
131+
}, {
140132
name: "duplicate option long names",
141133
builds: []func(){
142134
func() {
@@ -150,8 +142,7 @@ func TestBuilder(t *testing.T) {
150142
expPanicVals: []any{
151143
"command 'root' contains duplicate option long name 'aaa'",
152144
},
153-
},
154-
{
145+
}, {
155146
name: "options as positional arguments",
156147
builds: []func(){
157148
func() { NewCmd("root").Arg(NewOpt("o1")) },
@@ -161,8 +152,7 @@ func TestBuilder(t *testing.T) {
161152
errOptAsPosArg,
162153
errOptAsPosArg,
163154
},
164-
},
165-
{
155+
}, {
166156
name: "required positional arguments coming after optional ones",
167157
builds: []func(){
168158
func() {
@@ -181,8 +171,7 @@ func TestBuilder(t *testing.T) {
181171
errReqArgAfterOptional,
182172
errReqArgAfterOptional,
183173
},
184-
},
185-
{
174+
}, {
186175
name: "duplicate subcommand names",
187176
builds: []func(){
188177
func() {
@@ -205,8 +194,7 @@ func TestBuilder(t *testing.T) {
205194
"command 'root' contains duplicate subcommand name 'bb'",
206195
"command 'root subcmd' contains duplicate subcommand name 'aa'",
207196
},
208-
},
209-
{
197+
}, {
210198
name: "using NewVersionOpt with neither a short or long name",
211199
builds: []func(){
212200
func() { NewCmd("root").Opt(NewVersionOpt(0, "", VersionOptConfig{})) },

0 commit comments

Comments
 (0)