Codebase list golang-github-imdario-mergo / bd63fc79-05f6-4175-a57a-a1e9f503f8a2/upstream issue17_test.go
bd63fc79-05f6-4175-a57a-a1e9f503f8a2/upstream

Tree @bd63fc79-05f6-4175-a57a-a1e9f503f8a2/upstream (Download .tar.gz)

issue17_test.go @bd63fc79-05f6-4175-a57a-a1e9f503f8a2/upstreamraw · history · blame

package mergo_test

import (
	"encoding/json"
	"testing"

	"github.com/imdario/mergo"
)

func TestIssue17MergeWithOverwrite(t *testing.T) {
	var (
		request    = `{"timestamp":null, "name": "foo"}`
		maprequest = map[string]interface{}{
			"timestamp": nil,
			"name":      "foo",
			"newStuff":  "foo",
		}
	)

	var something map[string]interface{}
	if err := json.Unmarshal([]byte(request), &something); err != nil {
		t.Errorf("Error while Unmarshalling maprequest: %s", err)
	}

	if err := mergo.MergeWithOverwrite(&something, maprequest); err != nil {
		t.Errorf("Error while merging: %s", err)
	}
}