Apply the case of the CLI flags for the configuration
This commit is contained in:
parent
cd164de776
commit
91e63dea47
5 changed files with 174 additions and 43 deletions
|
@ -29,6 +29,16 @@ func TestParse(t *testing.T) {
|
|||
"traefik.foo": "true",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "bool value capitalized",
|
||||
args: []string{"--Foo"},
|
||||
element: &struct {
|
||||
Foo bool
|
||||
}{},
|
||||
expected: map[string]string{
|
||||
"traefik.Foo": "true",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "equal",
|
||||
args: []string{"--foo=bar"},
|
||||
|
@ -39,6 +49,16 @@ func TestParse(t *testing.T) {
|
|||
"traefik.foo": "bar",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "equal",
|
||||
args: []string{"--Foo=Bar"},
|
||||
element: &struct {
|
||||
Foo string
|
||||
}{},
|
||||
expected: map[string]string{
|
||||
"traefik.Foo": "Bar",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "space separated",
|
||||
args: []string{"--foo", "bar"},
|
||||
|
@ -49,6 +69,16 @@ func TestParse(t *testing.T) {
|
|||
"traefik.foo": "bar",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "space separated capitalized",
|
||||
args: []string{"--Foo", "Bar"},
|
||||
element: &struct {
|
||||
Foo string
|
||||
}{},
|
||||
expected: map[string]string{
|
||||
"traefik.Foo": "Bar",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "space separated with end of parameter",
|
||||
args: []string{"--foo=bir", "--", "--bar"},
|
||||
|
@ -91,6 +121,16 @@ func TestParse(t *testing.T) {
|
|||
"traefik.foo.name": "bar",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "map string capitalized",
|
||||
args: []string{"--foo.Name=Bar"},
|
||||
element: &struct {
|
||||
Foo map[string]string
|
||||
}{},
|
||||
expected: map[string]string{
|
||||
"traefik.foo.Name": "Bar",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "map struct",
|
||||
args: []string{"--foo.name.value=bar"},
|
||||
|
@ -199,6 +239,50 @@ func TestParse(t *testing.T) {
|
|||
"traefik.foo": "true",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "map string case sensitive",
|
||||
args: []string{"--foo.caseSensitiveName=barBoo"},
|
||||
element: &struct {
|
||||
Foo map[string]string
|
||||
}{},
|
||||
expected: map[string]string{
|
||||
"traefik.foo.caseSensitiveName": "barBoo",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "map struct with sub-map case senstitive",
|
||||
args: []string{"--foo.Name1.bar.name2.value=firstValue", "--foo.naMe1.bar.name2.value=secondValue"},
|
||||
element: &struct {
|
||||
Foo map[string]struct {
|
||||
Bar map[string]struct{ Value string }
|
||||
}
|
||||
}{},
|
||||
expected: map[string]string{
|
||||
"traefik.foo.Name1.bar.name2.value": "secondValue",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "map struct with sub-map and different case",
|
||||
args: []string{"--foo.Name1.bar.name2.value=firstValue", "--foo.naMe1.bar.name2.value=secondValue"},
|
||||
element: &struct {
|
||||
Foo map[string]struct {
|
||||
Bar map[string]struct{ Value string }
|
||||
}
|
||||
}{},
|
||||
expected: map[string]string{
|
||||
"traefik.foo.Name1.bar.name2.value": "secondValue",
|
||||
},
|
||||
},
|
||||
{
|
||||
desc: "slice with several flags 2 and different cases.",
|
||||
args: []string{"--foo", "bar", "--Foo", "baz"},
|
||||
element: &struct {
|
||||
Foo []string
|
||||
}{},
|
||||
expected: map[string]string{
|
||||
"traefik.foo": "bar,baz",
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, test := range testCases {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue