Package list golang-github-imdario-mergo / 7f088954-577d-41e8-86de-cb5d43e4e55e/main issue17_test.go
7f088954-577d-41e8-86de-cb5d43e4e55e/main

Tree @7f088954-577d-41e8-86de-cb5d43e4e55e/main (Download .tar.gz)

issue17_test.go @7f088954-577d-41e8-86de-cb5d43e4e55e/mainraw · history · blame

package mergo

import (
	"encoding/json"
	"testing"
)

var (
	request    = `{"timestamp":null, "name": "foo"}`
	maprequest = map[string]interface{}{
		"timestamp": nil,
		"name":      "foo",
		"newStuff":  "foo",
	}
)

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