...
1 package mergo_test
2
3 import (
4 "github.com/imdario/mergo"
5 "reflect"
6 "testing"
7 )
8
9 type structWithStringMap struct {
10 Data map[string]string
11 }
12
13 func TestIssue90(t *testing.T) {
14 dst := map[string]structWithStringMap{
15 "struct": {
16 Data: nil,
17 },
18 }
19 src := map[string]structWithStringMap{
20 "struct": {
21 Data: map[string]string{
22 "foo": "bar",
23 },
24 },
25 }
26 expected := map[string]structWithStringMap{
27 "struct": {
28 Data: map[string]string{
29 "foo": "bar",
30 },
31 },
32 }
33
34 err := mergo.Merge(&dst, src, mergo.WithOverride)
35 if err != nil {
36 t.Errorf("unexpected error %v", err)
37 }
38
39 if !reflect.DeepEqual(dst, expected) {
40 t.Errorf("expected: %#v\ngot: %#v", expected, dst)
41 }
42 }
43
View as plain text