@@ -29,6 +29,16 @@ func TestParse(t *testing.T) {
29
29
"traefik.foo" : "true" ,
30
30
},
31
31
},
32
+ {
33
+ desc : "bool value capitalized" ,
34
+ args : []string {"--Foo" },
35
+ element : & struct {
36
+ Foo bool
37
+ }{},
38
+ expected : map [string ]string {
39
+ "traefik.Foo" : "true" ,
40
+ },
41
+ },
32
42
{
33
43
desc : "equal" ,
34
44
args : []string {"--foo=bar" },
@@ -39,6 +49,16 @@ func TestParse(t *testing.T) {
39
49
"traefik.foo" : "bar" ,
40
50
},
41
51
},
52
+ {
53
+ desc : "equal" ,
54
+ args : []string {"--Foo=Bar" },
55
+ element : & struct {
56
+ Foo string
57
+ }{},
58
+ expected : map [string ]string {
59
+ "traefik.Foo" : "Bar" ,
60
+ },
61
+ },
42
62
{
43
63
desc : "space separated" ,
44
64
args : []string {"--foo" , "bar" },
@@ -49,6 +69,16 @@ func TestParse(t *testing.T) {
49
69
"traefik.foo" : "bar" ,
50
70
},
51
71
},
72
+ {
73
+ desc : "space separated capitalized" ,
74
+ args : []string {"--Foo" , "Bar" },
75
+ element : & struct {
76
+ Foo string
77
+ }{},
78
+ expected : map [string ]string {
79
+ "traefik.Foo" : "Bar" ,
80
+ },
81
+ },
52
82
{
53
83
desc : "space separated with end of parameter" ,
54
84
args : []string {"--foo=bir" , "--" , "--bar" },
@@ -91,6 +121,16 @@ func TestParse(t *testing.T) {
91
121
"traefik.foo.name" : "bar" ,
92
122
},
93
123
},
124
+ {
125
+ desc : "map string capitalized" ,
126
+ args : []string {"--foo.Name=Bar" },
127
+ element : & struct {
128
+ Foo map [string ]string
129
+ }{},
130
+ expected : map [string ]string {
131
+ "traefik.foo.Name" : "Bar" ,
132
+ },
133
+ },
94
134
{
95
135
desc : "map struct" ,
96
136
args : []string {"--foo.name.value=bar" },
@@ -199,6 +239,50 @@ func TestParse(t *testing.T) {
199
239
"traefik.foo" : "true" ,
200
240
},
201
241
},
242
+ {
243
+ desc : "map string case sensitive" ,
244
+ args : []string {"--foo.caseSensitiveName=barBoo" },
245
+ element : & struct {
246
+ Foo map [string ]string
247
+ }{},
248
+ expected : map [string ]string {
249
+ "traefik.foo.caseSensitiveName" : "barBoo" ,
250
+ },
251
+ },
252
+ {
253
+ desc : "map struct with sub-map case senstitive" ,
254
+ args : []string {"--foo.Name1.bar.name2.value=firstValue" , "--foo.naMe1.bar.name2.value=secondValue" },
255
+ element : & struct {
256
+ Foo map [string ]struct {
257
+ Bar map [string ]struct { Value string }
258
+ }
259
+ }{},
260
+ expected : map [string ]string {
261
+ "traefik.foo.Name1.bar.name2.value" : "secondValue" ,
262
+ },
263
+ },
264
+ {
265
+ desc : "map struct with sub-map and different case" ,
266
+ args : []string {"--foo.Name1.bar.name2.value=firstValue" , "--foo.naMe1.bar.name2.value=secondValue" },
267
+ element : & struct {
268
+ Foo map [string ]struct {
269
+ Bar map [string ]struct { Value string }
270
+ }
271
+ }{},
272
+ expected : map [string ]string {
273
+ "traefik.foo.Name1.bar.name2.value" : "secondValue" ,
274
+ },
275
+ },
276
+ {
277
+ desc : "slice with several flags 2 and different cases." ,
278
+ args : []string {"--foo" , "bar" , "--Foo" , "baz" },
279
+ element : & struct {
280
+ Foo []string
281
+ }{},
282
+ expected : map [string ]string {
283
+ "traefik.foo" : "bar,baz" ,
284
+ },
285
+ },
202
286
}
203
287
204
288
for _ , test := range testCases {
0 commit comments