Fix backwards compatibility

Signed-off-by: Martin Hickey <martin.hickey@ie.ibm.com>
pull/10336/merge
Martin Hickey 2 years ago
parent a59e584684
commit b6fef6c466

@ -278,14 +278,14 @@ func (t *parser) key(data map[string]interface{}, nestedNameLevel int) (reterr e
}
// Recurse
if e := t.key(inner, nestedNameLevel); e != nil {
return e
}
if len(inner) == 0 {
e := t.key(inner, nestedNameLevel)
if e == nil && len(inner) == 0 {
return errors.Errorf("key map %q has no value", string(k))
}
if len(inner) != 0 {
set(data, string(k), inner)
return nil
}
return e
}
}
}

@ -248,9 +248,8 @@ func TestParseSet(t *testing.T) {
err: true,
},
{
"name1.name2=",
map[string]interface{}{},
false,
str: "name1.name2=",
expect: map[string]interface{}{"name1": map[string]interface{}{"name2": ""}},
},
{
str: "name1.=name2",
@ -770,15 +769,19 @@ func TestParseSetNestedLevels(t *testing.T) {
str string
expect map[string]interface{}
err bool
errStr string
}{
{
"outer.middle.inner=value",
map[string]interface{}{"outer": map[string]interface{}{"middle": map[string]interface{}{"inner": "value"}}},
false,
"",
},
{
str: keyMultipleNestedLevels + "=value",
err: true,
errStr: fmt.Sprintf("value name nested level is greater than maximum supported nested level of %d",
MaxNestedNameLevel),
},
}
@ -786,6 +789,11 @@ func TestParseSetNestedLevels(t *testing.T) {
got, err := Parse(tt.str)
if err != nil {
if tt.err {
if tt.errStr != "" {
if err.Error() != tt.errStr {
t.Errorf("Expected error: %s. Got error: %s", tt.errStr, err.Error())
}
}
continue
}
t.Fatalf("%s: %s", tt.str, err)

Loading…
Cancel
Save