Skip to content

Commit

Permalink
refactor: update pin tests to use /ipfs
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Oct 6, 2023
1 parent 77b6c45 commit 9252a2b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
30 changes: 15 additions & 15 deletions coreiface/tests/pin.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,12 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
t.Fatal(err)
}

err = api.Pin().Add(ctx, newIPLDPath(t, nd2.Cid()))
err = api.Pin().Add(ctx, path.FromCid(nd2.Cid()))
if err != nil {
t.Fatal(err)
}

err = api.Pin().Add(ctx, newIPLDPath(t, nd3.Cid()), opt.Pin.Recursive(false))
err = api.Pin().Add(ctx, path.FromCid(nd3.Cid()), opt.Pin.Recursive(false))
if err != nil {
t.Fatal(err)
}
Expand All @@ -161,7 +161,7 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
t.Errorf("unexpected pin list len: %d", len(list))
}

if list[0].Path().String() != newIPLDPath(t, nd3.Cid()).String() {
if list[0].Path().String() != path.FromCid(nd3.Cid()).String() {
t.Errorf("unexpected path, %s != %s", list[0].Path().String(), path.FromCid(nd3.Cid()).String())
}

Expand All @@ -174,8 +174,8 @@ func (tp *TestSuite) TestPinRecursive(t *testing.T) {
t.Errorf("unexpected pin list len: %d", len(list))
}

if list[0].Path().String() != newIPLDPath(t, nd2.Cid()).String() {
t.Errorf("unexpected path, %s != %s", list[0].Path().String(), newIPLDPath(t, nd2.Cid()).String())
if list[0].Path().String() != path.FromCid(nd2.Cid()).String() {
t.Errorf("unexpected path, %s != %s", list[0].Path().String(), path.FromCid(nd2.Cid()).String())
}

list, err = accPins(api.Pin().Ls(ctx, opt.Pin.Ls.Indirect()))
Expand Down Expand Up @@ -258,12 +258,12 @@ func (tp *TestSuite) TestPinLsIndirect(t *testing.T) {

leaf, parent, grandparent := getThreeChainedNodes(t, ctx, api, "foo")

err = api.Pin().Add(ctx, newIPLDPath(t, grandparent.Cid()))
err = api.Pin().Add(ctx, path.FromCid(grandparent.Cid()))
if err != nil {
t.Fatal(err)
}

err = api.Pin().Add(ctx, newIPLDPath(t, parent.Cid()), opt.Pin.Recursive(false))
err = api.Pin().Add(ctx, path.FromCid(parent.Cid()), opt.Pin.Recursive(false))
if err != nil {
t.Fatal(err)
}
Expand Down Expand Up @@ -292,12 +292,12 @@ func (tp *TestSuite) TestPinLsPredenceRecursiveIndirect(t *testing.T) {
// Test recursive > indirect
leaf, parent, grandparent := getThreeChainedNodes(t, ctx, api, "recursive > indirect")

err = api.Pin().Add(ctx, newIPLDPath(t, grandparent.Cid()))
err = api.Pin().Add(ctx, path.FromCid(grandparent.Cid()))
if err != nil {
t.Fatal(err)
}

err = api.Pin().Add(ctx, newIPLDPath(t, parent.Cid()))
err = api.Pin().Add(ctx, path.FromCid(parent.Cid()))
if err != nil {
t.Fatal(err)
}
Expand All @@ -316,12 +316,12 @@ func (tp *TestSuite) TestPinLsPrecedenceDirectIndirect(t *testing.T) {
// Test direct > indirect
leaf, parent, grandparent := getThreeChainedNodes(t, ctx, api, "direct > indirect")

err = api.Pin().Add(ctx, newIPLDPath(t, grandparent.Cid()))
err = api.Pin().Add(ctx, path.FromCid(grandparent.Cid()))
if err != nil {
t.Fatal(err)
}

err = api.Pin().Add(ctx, newIPLDPath(t, parent.Cid()), opt.Pin.Recursive(false))
err = api.Pin().Add(ctx, path.FromCid(parent.Cid()), opt.Pin.Recursive(false))
if err != nil {
t.Fatal(err)
}
Expand All @@ -340,24 +340,24 @@ func (tp *TestSuite) TestPinLsPrecedenceRecursiveDirect(t *testing.T) {
// Test recursive > direct
leaf, parent, grandparent := getThreeChainedNodes(t, ctx, api, "recursive + direct = error")

err = api.Pin().Add(ctx, newIPLDPath(t, parent.Cid()))
err = api.Pin().Add(ctx, path.FromCid(parent.Cid()))
if err != nil {
t.Fatal(err)
}

err = api.Pin().Add(ctx, newIPLDPath(t, parent.Cid()), opt.Pin.Recursive(false))
err = api.Pin().Add(ctx, path.FromCid(parent.Cid()), opt.Pin.Recursive(false))
if err == nil {
t.Fatal("expected error directly pinning a recursively pinned node")
}

assertPinTypes(t, ctx, api, []cidContainer{parent}, []cidContainer{}, []cidContainer{leaf})

err = api.Pin().Add(ctx, newIPLDPath(t, grandparent.Cid()), opt.Pin.Recursive(false))
err = api.Pin().Add(ctx, path.FromCid(grandparent.Cid()), opt.Pin.Recursive(false))
if err != nil {
t.Fatal(err)
}

err = api.Pin().Add(ctx, newIPLDPath(t, grandparent.Cid()))
err = api.Pin().Add(ctx, path.FromCid(grandparent.Cid()))
if err != nil {
t.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion coreiface/tests/unixfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -552,7 +552,7 @@ func (tp *TestSuite) TestAddPinned(t *testing.T) {
t.Fatalf("expected 1 pin, got %d", len(pins))
}

if pins[0].Path().String() != "/ipld/QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk" {
if pins[0].Path().String() != "/ipfs/QmQy2Dw4Wk7rdJKjThjYXzfFJNaRKRHhHP5gHHXroJMYxk" {
t.Fatalf("got unexpected pin: %s", pins[0].Path().String())
}
}
Expand Down

0 comments on commit 9252a2b

Please sign in to comment.