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

Function TestDotParameter

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

Source from the content-addressed store, hash-verified

2222}
2223
2224func TestDotParameter(t *testing.T) {
2225 v := New()
2226
2227 v.SetConfigType("json")
2228
2229 // Read the YAML data into Viper configuration
2230 require.NoError(t, v.ReadConfig(bytes.NewBuffer(jsonExample)), "Error reading YAML data")
2231
2232 // should take precedence over batters defined in jsonExample
2233 r := bytes.NewReader([]byte(`{ "batters.batter": [ { "type": "Small" } ] }`))
2234 v.unmarshalReader(r, v.config)
2235
2236 actual := v.Get("batters.batter")
2237 expected := []any{map[string]any{"type": "Small"}}
2238 assert.Equal(t, expected, actual)
2239}
2240
2241func TestCaseInsensitive(t *testing.T) {
2242 for _, config := range []struct {

Callers

nothing calls this directly

Calls 5

NewFunction · 0.85
SetConfigTypeMethod · 0.80
ReadConfigMethod · 0.80
unmarshalReaderMethod · 0.80
GetMethod · 0.65

Tested by

no test coverage detected