...
1 package mergo_test
2
3 import (
4 "testing"
5
6 "github.com/imdario/mergo"
7 )
8
9 func TestIssue123(t *testing.T) {
10 src := map[string]interface{}{
11 "col1": nil,
12 "col2": 4,
13 "col3": nil,
14 }
15 dst := map[string]interface{}{
16 "col1": 2,
17 "col2": 3,
18 "col3": 3,
19 }
20
21
22 if err := mergo.Merge(&dst, src, mergo.WithOverride); err != nil {
23 t.Fatal(err)
24 }
25 testCases := []struct {
26 expected interface{}
27 key string
28 }{
29 {
30 nil,
31 "col1",
32 },
33 {
34 4,
35 "col2",
36 },
37 {
38 nil,
39 "col3",
40 },
41 }
42 for _, tC := range testCases {
43 if dst[tC.key] != tC.expected {
44 t.Fatalf("expected %v in dst[%q], got %v", tC.expected, tC.key, dst[tC.key])
45 }
46 }
47 }
48
View as plain text