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

Function TestMergeConfigMap

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

Source from the content-addressed store, hash-verified

2132}
2133
2134func TestMergeConfigMap(t *testing.T) {
2135 v := New()
2136 v.SetConfigType("yml")
2137 err := v.ReadConfig(bytes.NewBuffer(yamlMergeExampleTgt))
2138 require.NoError(t, err)
2139
2140 assertFn := func(i int) {
2141 large := v.GetInt64("hello.largenum")
2142 pop := v.GetInt("hello.pop")
2143 assert.Equal(t, int64(765432101234567), large)
2144 assert.Equal(t, i, pop)
2145 }
2146
2147 assertFn(37890)
2148
2149 update := map[string]any{
2150 "Hello": map[string]any{
2151 "Pop": 1234,
2152 },
2153 "World": map[any]any{
2154 "Rock": 345,
2155 },
2156 }
2157
2158 err = v.MergeConfigMap(update)
2159 require.NoError(t, err)
2160
2161 assert.Equal(t, 345, v.GetInt("world.rock"))
2162
2163 assertFn(1234)
2164}
2165
2166func TestUnmarshalingWithAliases(t *testing.T) {
2167 v := New()

Callers

nothing calls this directly

Calls 6

NewFunction · 0.85
SetConfigTypeMethod · 0.80
ReadConfigMethod · 0.80
GetInt64Method · 0.80
GetIntMethod · 0.80
MergeConfigMapMethod · 0.80

Tested by

no test coverage detected