Skip to content

Commit

Permalink
drop external dep and update copy function
Browse files Browse the repository at this point in the history
  • Loading branch information
kjzz committed Sep 6, 2018
1 parent a8cc0b9 commit 83a3ec9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
8 changes: 4 additions & 4 deletions daghelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,10 @@ func Copy(ctx context.Context, from, to DAGService, root *cid.Cid) error {
if err != nil {
return err
}
err = to.Add(ctx, node)
if err != nil {
return err
}
}
err = to.Add(ctx, node)
if err != nil {
return err
}
return nil
}
Expand Down
11 changes: 4 additions & 7 deletions daghelpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"github.com/ipfs/go-cid"
mh "github.com/multiformats/go-multihash"
"github.com/stretchr/testify/assert"
"testing"
)

Expand Down Expand Up @@ -132,13 +131,11 @@ func TestCopy(t *testing.T) {
}

r, err := to.Get(ctx, root.Cid())
if err != nil {
t.Error(err)
if err != nil || len(r.Links()) != 2 {
t.Error("fail to copy dag")
}
l1, err := to.Get(ctx, l11.Cid())
if err != nil {
t.Error(err)
if err != nil || len(l1.Links()) != 3 {
t.Error("fail to copy dag")
}
assert.Equal(t, len(r.Links()), 2)
assert.Equal(t, len(l1.Links()), 3)
}

0 comments on commit 83a3ec9

Please sign in to comment.