(t *testing.T)
| 2062 | `) |
| 2063 | |
| 2064 | func TestMergeConfig(t *testing.T) { |
| 2065 | v := New() |
| 2066 | v.SetConfigType("yml") |
| 2067 | err := v.ReadConfig(bytes.NewBuffer(yamlMergeExampleTgt)) |
| 2068 | require.NoError(t, err) |
| 2069 | |
| 2070 | assert.Equal(t, 37890, v.GetInt("hello.pop")) |
| 2071 | assert.Equal(t, int32(37890), v.GetInt32("hello.pop")) |
| 2072 | assert.Equal(t, int64(765432101234567), v.GetInt64("hello.largenum")) |
| 2073 | assert.Equal(t, uint8(2), v.GetUint8("hello.pop")) |
| 2074 | assert.Equal(t, uint(37890), v.GetUint("hello.pop")) |
| 2075 | assert.Equal(t, uint16(37890), v.GetUint16("hello.pop")) |
| 2076 | assert.Equal(t, uint32(37890), v.GetUint32("hello.pop")) |
| 2077 | assert.Equal(t, uint64(9223372036854775808), v.GetUint64("hello.num2pow63")) |
| 2078 | assert.Len(t, v.GetStringSlice("hello.world"), 4) |
| 2079 | assert.Empty(t, v.GetString("fu")) |
| 2080 | |
| 2081 | err = v.MergeConfig(bytes.NewBuffer(yamlMergeExampleSrc)) |
| 2082 | require.NoError(t, err) |
| 2083 | |
| 2084 | assert.Equal(t, 45000, v.GetInt("hello.pop")) |
| 2085 | assert.Equal(t, int32(45000), v.GetInt32("hello.pop")) |
| 2086 | assert.Equal(t, int64(7654321001234567), v.GetInt64("hello.largenum")) |
| 2087 | assert.Len(t, v.GetStringSlice("hello.world"), 4) |
| 2088 | assert.Len(t, v.GetStringSlice("hello.universe"), 2) |
| 2089 | assert.Len(t, v.GetIntSlice("hello.ints"), 2) |
| 2090 | assert.Equal(t, "bar", v.GetString("fu")) |
| 2091 | } |
| 2092 | |
| 2093 | func TestMergeConfigWithSetConfigFile(t *testing.T) { |
| 2094 | v := New() |
nothing calls this directly
no test coverage detected