Commit 33d445a6 authored by Łukasz Magiera's avatar Łukasz Magiera

path: fix tests

parent 2b9bff75
......@@ -110,10 +110,7 @@ func (tp *provider) TestBlockGet(t *testing.T) {
t.Error("didn't get correct data back")
}
p, err := coreiface.ParsePath("/ipfs/" + res.Path().Cid().String())
if err != nil {
t.Fatal(err)
}
p := coreiface.ParsePath("/ipfs/" + res.Path().Cid().String())
rp, err := api.ResolvePath(ctx, p)
if err != nil {
......
......@@ -113,10 +113,7 @@ func (tp *provider) TestDagPath(t *testing.T) {
t.Fatal(err)
}
p, err := coreiface.ParsePath(path.Join(nd.Cid().String(), "lnk"))
if err != nil {
t.Fatal(err)
}
p := coreiface.ParsePath(path.Join(nd.Cid().String(), "lnk"))
rp, err := api.ResolvePath(ctx, p)
if err != nil {
......
......@@ -35,11 +35,7 @@ func addTestObject(ctx context.Context, api coreiface.CoreAPI) (coreiface.Path,
}
func appendPath(p coreiface.Path, sub string) coreiface.Path {
p, err := coreiface.ParsePath(path.Join(p.String(), sub))
if err != nil {
panic(err)
}
return p
return coreiface.ParsePath(path.Join(p.String(), sub))
}
func (tp *provider) TestPublishResolve(t *testing.T) {
......
......@@ -75,12 +75,7 @@ func (tp *provider) TestPathRemainder(t *testing.T) {
t.Fatal(err)
}
p1, err := coreiface.ParsePath(nd.String() + "/foo/bar")
if err != nil {
t.Fatal(err)
}
rp1, err := api.ResolvePath(ctx, p1)
rp1, err := api.ResolvePath(ctx, coreiface.ParsePath(nd.String()+"/foo/bar"))
if err != nil {
t.Fatal(err)
}
......@@ -111,12 +106,7 @@ func (tp *provider) TestEmptyPathRemainder(t *testing.T) {
t.Fatal(err)
}
p1, err := coreiface.ParsePath(nd.Cid().String())
if err != nil {
t.Fatal(err)
}
rp1, err := api.ResolvePath(ctx, p1)
rp1, err := api.ResolvePath(ctx, coreiface.ParsePath(nd.Cid().String()))
if err != nil {
t.Fatal(err)
}
......@@ -147,12 +137,7 @@ func (tp *provider) TestInvalidPathRemainder(t *testing.T) {
t.Fatal(err)
}
p1, err := coreiface.ParsePath("/ipld/" + nd.Cid().String() + "/bar/baz")
if err != nil {
t.Fatal(err)
}
_, err = api.ResolvePath(ctx, p1)
_, err = api.ResolvePath(ctx, coreiface.ParsePath("/ipld/"+nd.Cid().String()+"/bar/baz"))
if err == nil || !strings.Contains(err.Error(), "no such link found") {
t.Fatalf("unexpected error: %s", err)
}
......@@ -188,12 +173,7 @@ func (tp *provider) TestPathRoot(t *testing.T) {
t.Fatal(err)
}
p1, err := coreiface.ParsePath("/ipld/" + nd.Cid().String() + "/foo")
if err != nil {
t.Fatal(err)
}
rp, err := api.ResolvePath(ctx, p1)
rp, err := api.ResolvePath(ctx, coreiface.ParsePath("/ipld/"+nd.Cid().String()+"/foo"))
if err != nil {
t.Fatal(err)
}
......@@ -208,10 +188,7 @@ func (tp *provider) TestPathRoot(t *testing.T) {
}
func (tp *provider) TestPathJoin(t *testing.T) {
p1, err := coreiface.ParsePath("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz")
if err != nil {
t.Fatal(err)
}
p1 := coreiface.ParsePath("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz")
if coreiface.Join(p1, "foo").String() != "/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz/foo" {
t.Error("unexpected path")
......
......@@ -592,10 +592,7 @@ func (tp *provider) TestGetEmptyFile(t *testing.T) {
t.Fatal(err)
}
emptyFilePath, err := coreiface.ParsePath(emptyFile)
if err != nil {
t.Fatal(err)
}
emptyFilePath := coreiface.ParsePath(emptyFile)
r, err := api.Unixfs().Get(ctx, emptyFilePath)
if err != nil {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment