Copy should return a new document, not interface{}

This commit is contained in:
Tobie Morgan Hitchcock 2017-11-16 19:08:03 +00:00
parent 33391e0a28
commit 3f68f1318c
2 changed files with 3 additions and 3 deletions

View file

@ -57,8 +57,8 @@ func (d *Doc) Data() interface{} {
}
// Copy returns a duplicated copy of the internal data object.
func (d *Doc) Copy() (i interface{}) {
return deep.Copy(d.data)
func (d *Doc) Copy() *Doc {
return &Doc{data: deep.Copy(d.data)}
}
// Encode encodes the data object to a byte slice.

View file

@ -1048,7 +1048,7 @@ func TestOperations(t *testing.T) {
// ----------------------------------------------------------------------------------------------------
Convey("Can copy object", t, func() {
So(doc.Copy(), ShouldResemble, doc.Data())
So(doc.Copy().Data(), ShouldResemble, doc.Data())
})
// ----------------------------------------------------------------------------------------------------