...

Source file src/dario.cat/mergo/issue121_test.go

Documentation: dario.cat/mergo

     1  package mergo_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"dario.cat/mergo"
     7  )
     8  
     9  func TestIssue121WithSliceDeepCopy(t *testing.T) {
    10  	dst := map[string]interface{}{
    11  		"inter": map[string]interface{}{
    12  			"a": "1",
    13  			"b": "2",
    14  		},
    15  	}
    16  
    17  	src := map[string]interface{}{
    18  		"inter": map[string]interface{}{
    19  			"a": "3",
    20  			"c": "4",
    21  		},
    22  	}
    23  
    24  	if err := mergo.Merge(&dst, src, mergo.WithSliceDeepCopy); err != nil {
    25  		t.Errorf("Error during the merge: %v", err)
    26  	}
    27  
    28  	if dst["inter"].(map[string]interface{})["a"].(string) != "3" {
    29  		t.Error("inter.a should equal '3'")
    30  	}
    31  
    32  	if dst["inter"].(map[string]interface{})["c"].(string) != "4" {
    33  		t.Error("inter.c should equal '4'")
    34  	}
    35  }
    36  

View as plain text