...

Source file src/github.com/imdario/mergo/issue23_test.go

Documentation: github.com/imdario/mergo

     1  package mergo_test
     2  
     3  import (
     4  	"testing"
     5  	"time"
     6  
     7  	"github.com/imdario/mergo"
     8  )
     9  
    10  type document struct {
    11  	Created *time.Time
    12  }
    13  
    14  func TestIssue23MergeWithOverwrite(t *testing.T) {
    15  	now := time.Now()
    16  	dst := document{
    17  		&now,
    18  	}
    19  	expected := time.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC)
    20  	src := document{
    21  		&expected,
    22  	}
    23  
    24  	if err := mergo.MergeWithOverwrite(&dst, src); err != nil {
    25  		t.Errorf("Error while merging %s", err)
    26  	}
    27  
    28  	if !dst.Created.Equal(*src.Created) { //--> https://golang.org/pkg/time/#pkg-overview
    29  		t.Errorf("Created not merged in properly: dst.Created(%v) != src.Created(%v)", dst.Created, src.Created)
    30  	}
    31  }
    32  

View as plain text