mirror of
https://github.com/spf13/viper
synced 2025-05-06 12:17:18 +00:00
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:
parent
86fffbd28c
commit
63a39fe605
1 changed files with 11 additions and 0 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Reference in a new issue