Added test case for merging configs, where target is null, and source is not null

This commit is contained in:
Illarion Kovalchuk 2021-10-14 16:29:39 +03:00 committed by Márk Sági-Kazár
parent 0353c6ea50
commit 97664ba020
2 changed files with 7 additions and 1 deletions

View file

@ -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

View file

@ -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) {