Tests: add a test for checking precedence of dot-containing keys.

if config["foo"]["bar"] and config["foo.bar"] coexist, the latter value
should be used (as described in README).
This commit is contained in:
Benoit Masson 2016-09-29 15:52:01 +02:00
parent 86fffbd28c
commit 63a39fe605

View file

@ -923,6 +923,17 @@ func TestShadowedNestedValue(t *testing.T) {
assert.Equal(t, polyester, GetString("clothing.shirt"))
}
func TestDotParameter(t *testing.T) {
initJSON()
// shoud take precedence over batters defined in jsonExample
r := bytes.NewReader([]byte(`{ "batters.batter": [ { "type": "Small" } ] }`))
unmarshalReader(r, v.config)
actual := Get("batters.batter")
expected := []interface{}{map[string]interface{}{"type": "Small"}}
assert.Equal(t, expected, actual)
}
func TestGetBool(t *testing.T) {
key := "BooleanKey"
v = New()