Codebase list golang-github-imdario-mergo / run/a962cd97-6e5e-4cd5-a9cf-58dfd3df3e48/main issue121_test.go
run/a962cd97-6e5e-4cd5-a9cf-58dfd3df3e48/main

Tree @run/a962cd97-6e5e-4cd5-a9cf-58dfd3df3e48/main (Download .tar.gz)

issue121_test.go @run/a962cd97-6e5e-4cd5-a9cf-58dfd3df3e48/main

6e78443
 
 
 
 
d75ad88
6e78443
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
package mergo_test

import (
	"testing"

	"dario.cat/mergo"
)

func TestIssue121WithSliceDeepCopy(t *testing.T) {
	dst := map[string]interface{}{
		"inter": map[string]interface{}{
			"a": "1",
			"b": "2",
		},
	}

	src := map[string]interface{}{
		"inter": map[string]interface{}{
			"a": "3",
			"c": "4",
		},
	}

	if err := mergo.Merge(&dst, src, mergo.WithSliceDeepCopy); err != nil {
		t.Errorf("Error during the merge: %v", err)
	}

	if dst["inter"].(map[string]interface{})["a"].(string) != "3" {
		t.Error("inter.a should equal '3'")
	}

	if dst["inter"].(map[string]interface{})["c"].(string) != "4" {
		t.Error("inter.c should equal '4'")
	}
}