MCPcopy
hub / github.com/spf13/viper / TestShadowedNestedValue

Function TestShadowedNestedValue

viper_test.go:2198–2222  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2196}
2197
2198func TestShadowedNestedValue(t *testing.T) {
2199 v := New()
2200 config := `name: steve
2201clothing:
2202 jacket: leather
2203 trousers: denim
2204 pants:
2205 size: large
2206`
2207 initConfig("yaml", config, v)
2208
2209 assert.Equal(t, "steve", v.GetString("name"))
2210
2211 polyester := "polyester"
2212 v.SetDefault("clothing.shirt", polyester)
2213 v.SetDefault("clothing.jacket.price", 100)
2214
2215 assert.Equal(t, "leather", v.GetString("clothing.jacket"))
2216 assert.Nil(t, v.Get("clothing.jacket.price"))
2217 assert.Equal(t, polyester, v.GetString("clothing.shirt"))
2218
2219 clothingSettings := v.AllSettings()["clothing"].(map[string]any)
2220 assert.Equal(t, "leather", clothingSettings["jacket"])
2221 assert.Equal(t, polyester, clothingSettings["shirt"])
2222}
2223
2224func TestDotParameter(t *testing.T) {
2225 v := New()

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
initConfigFunction · 0.85
GetStringMethod · 0.80
SetDefaultMethod · 0.80
AllSettingsMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected