Skip to content

Commit

Permalink
Update tests to use ipld.IsNotFound to check for notfound errors
Browse files Browse the repository at this point in the history
This commit was moved from ipfs/interface-go-ipfs-core@01ee941
  • Loading branch information
hsanjuan authored and Jorropo committed Mar 17, 2022
1 parent 9c1a747 commit 2263eca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions coreiface/tests/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"testing"

ipld "github.com/ipfs/go-ipld-format"
coreiface "github.com/ipfs/interface-go-ipfs-core"
opt "github.com/ipfs/interface-go-ipfs-core/options"
"github.com/ipfs/interface-go-ipfs-core/path"
Expand Down Expand Up @@ -179,15 +180,15 @@ func (tp *TestSuite) TestBlockRm(t *testing.T) {
if err == nil {
t.Fatal("expected err to exist")
}
if !strings.Contains(err.Error(), "blockservice: key not found") {
if !ipld.IsNotFound(err) {
t.Errorf("unexpected error; %s", err.Error())
}

err = api.Block().Rm(ctx, res.Path())
if err == nil {
t.Fatal("expected err to exist")
}
if !strings.Contains(err.Error(), "blockstore: block not found") {
if !strings.Contains(err.Error(), "not found") {
t.Errorf("unexpected error; %s", err.Error())
}

Expand Down
8 changes: 5 additions & 3 deletions coreiface/tests/unixfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"context"
"encoding/hex"
"fmt"
"github.com/ipfs/interface-go-ipfs-core/path"
"io"
"io/ioutil"
"math"
Expand All @@ -16,12 +15,15 @@ import (
"sync"
"testing"

"github.com/ipfs/interface-go-ipfs-core/path"

coreiface "github.com/ipfs/interface-go-ipfs-core"
"github.com/ipfs/interface-go-ipfs-core/options"

"github.com/ipfs/go-cid"
"github.com/ipfs/go-ipfs-files"
files "github.com/ipfs/go-ipfs-files"
cbor "github.com/ipfs/go-ipld-cbor"
ipld "github.com/ipfs/go-ipld-format"
mdag "github.com/ipfs/go-merkledag"
"github.com/ipfs/go-unixfs"
"github.com/ipfs/go-unixfs/importer/helpers"
Expand Down Expand Up @@ -576,7 +578,7 @@ func (tp *TestSuite) TestAddHashOnly(t *testing.T) {
if err == nil {
t.Fatal("expected an error")
}
if !strings.Contains(err.Error(), "blockservice: key not found") {
if !ipld.IsNotFound(err) {
t.Errorf("unxepected error: %s", err.Error())
}
}
Expand Down

0 comments on commit 2263eca

Please sign in to comment.