forked from mirror/viper
Added test case for merging configs, where target is null, and source is not null
This commit is contained in:
parent
0353c6ea50
commit
97664ba020
2
viper.go
2
viper.go
|
@ -1808,7 +1808,7 @@ func mergeMaps(
|
|||
v.logger.Trace("merging maps")
|
||||
tsv, ok := sv.(map[string]interface{})
|
||||
if !ok {
|
||||
jww.ERROR.Printf(
|
||||
v.logger.Error(
|
||||
"Could not cast sv to map[string]interface{}; key=%s, st=%v, tt=%v, sv=%v, tv=%v",
|
||||
sk, svType, tvType, sv, tv)
|
||||
continue
|
||||
|
|
|
@ -1915,6 +1915,7 @@ fu: bar
|
|||
var jsonMergeExampleTgt = []byte(`
|
||||
{
|
||||
"hello": {
|
||||
"foo": null,
|
||||
"pop": 123456
|
||||
}
|
||||
}
|
||||
|
@ -1923,6 +1924,7 @@ var jsonMergeExampleTgt = []byte(`
|
|||
var jsonMergeExampleSrc = []byte(`
|
||||
{
|
||||
"hello": {
|
||||
"foo": "foo str",
|
||||
"pop": "pop str"
|
||||
}
|
||||
}
|
||||
|
@ -2014,6 +2016,10 @@ func TestMergeConfigOverrideType(t *testing.T) {
|
|||
if pop := v.GetString("hello.pop"); pop != "pop str" {
|
||||
t.Fatalf("pop != \"pop str\", = %s", pop)
|
||||
}
|
||||
|
||||
if foo := v.GetString("hello.foo"); foo != "foo str" {
|
||||
t.Fatalf("foo != \"foo str\", = %s", foo)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMergeConfigNoMerge(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue