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) { ...@@ -110,10 +110,7 @@ func (tp *provider) TestBlockGet(t *testing.T) {
t.Error("didn't get correct data back") t.Error("didn't get correct data back")
} }
p, err := coreiface.ParsePath("/ipfs/" + res.Path().Cid().String()) p := coreiface.ParsePath("/ipfs/" + res.Path().Cid().String())
if err != nil {
t.Fatal(err)
}
rp, err := api.ResolvePath(ctx, p) rp, err := api.ResolvePath(ctx, p)
if err != nil { if err != nil {
......
...@@ -113,10 +113,7 @@ func (tp *provider) TestDagPath(t *testing.T) { ...@@ -113,10 +113,7 @@ func (tp *provider) TestDagPath(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
p, err := coreiface.ParsePath(path.Join(nd.Cid().String(), "lnk")) p := coreiface.ParsePath(path.Join(nd.Cid().String(), "lnk"))
if err != nil {
t.Fatal(err)
}
rp, err := api.ResolvePath(ctx, p) rp, err := api.ResolvePath(ctx, p)
if err != nil { if err != nil {
......
...@@ -35,11 +35,7 @@ func addTestObject(ctx context.Context, api coreiface.CoreAPI) (coreiface.Path, ...@@ -35,11 +35,7 @@ func addTestObject(ctx context.Context, api coreiface.CoreAPI) (coreiface.Path,
} }
func appendPath(p coreiface.Path, sub string) coreiface.Path { func appendPath(p coreiface.Path, sub string) coreiface.Path {
p, err := coreiface.ParsePath(path.Join(p.String(), sub)) return coreiface.ParsePath(path.Join(p.String(), sub))
if err != nil {
panic(err)
}
return p
} }
func (tp *provider) TestPublishResolve(t *testing.T) { func (tp *provider) TestPublishResolve(t *testing.T) {
......
...@@ -75,12 +75,7 @@ func (tp *provider) TestPathRemainder(t *testing.T) { ...@@ -75,12 +75,7 @@ func (tp *provider) TestPathRemainder(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
p1, err := coreiface.ParsePath(nd.String() + "/foo/bar") rp1, err := api.ResolvePath(ctx, coreiface.ParsePath(nd.String()+"/foo/bar"))
if err != nil {
t.Fatal(err)
}
rp1, err := api.ResolvePath(ctx, p1)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
...@@ -111,12 +106,7 @@ func (tp *provider) TestEmptyPathRemainder(t *testing.T) { ...@@ -111,12 +106,7 @@ func (tp *provider) TestEmptyPathRemainder(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
p1, err := coreiface.ParsePath(nd.Cid().String()) rp1, err := api.ResolvePath(ctx, coreiface.ParsePath(nd.Cid().String()))
if err != nil {
t.Fatal(err)
}
rp1, err := api.ResolvePath(ctx, p1)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
...@@ -147,12 +137,7 @@ func (tp *provider) TestInvalidPathRemainder(t *testing.T) { ...@@ -147,12 +137,7 @@ func (tp *provider) TestInvalidPathRemainder(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
p1, err := coreiface.ParsePath("/ipld/" + nd.Cid().String() + "/bar/baz") _, err = api.ResolvePath(ctx, coreiface.ParsePath("/ipld/"+nd.Cid().String()+"/bar/baz"))
if err != nil {
t.Fatal(err)
}
_, err = api.ResolvePath(ctx, p1)
if err == nil || !strings.Contains(err.Error(), "no such link found") { if err == nil || !strings.Contains(err.Error(), "no such link found") {
t.Fatalf("unexpected error: %s", err) t.Fatalf("unexpected error: %s", err)
} }
...@@ -188,12 +173,7 @@ func (tp *provider) TestPathRoot(t *testing.T) { ...@@ -188,12 +173,7 @@ func (tp *provider) TestPathRoot(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
p1, err := coreiface.ParsePath("/ipld/" + nd.Cid().String() + "/foo") rp, err := api.ResolvePath(ctx, coreiface.ParsePath("/ipld/"+nd.Cid().String()+"/foo"))
if err != nil {
t.Fatal(err)
}
rp, err := api.ResolvePath(ctx, p1)
if err != nil { if err != nil {
t.Fatal(err) t.Fatal(err)
} }
...@@ -208,10 +188,7 @@ func (tp *provider) TestPathRoot(t *testing.T) { ...@@ -208,10 +188,7 @@ func (tp *provider) TestPathRoot(t *testing.T) {
} }
func (tp *provider) TestPathJoin(t *testing.T) { func (tp *provider) TestPathJoin(t *testing.T) {
p1, err := coreiface.ParsePath("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz") p1 := coreiface.ParsePath("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz")
if err != nil {
t.Fatal(err)
}
if coreiface.Join(p1, "foo").String() != "/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz/foo" { if coreiface.Join(p1, "foo").String() != "/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz/foo" {
t.Error("unexpected path") t.Error("unexpected path")
......
...@@ -592,10 +592,7 @@ func (tp *provider) TestGetEmptyFile(t *testing.T) { ...@@ -592,10 +592,7 @@ func (tp *provider) TestGetEmptyFile(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
emptyFilePath, err := coreiface.ParsePath(emptyFile) emptyFilePath := coreiface.ParsePath(emptyFile)
if err != nil {
t.Fatal(err)
}
r, err := api.Unixfs().Get(ctx, emptyFilePath) r, err := api.Unixfs().Get(ctx, emptyFilePath)
if err != nil { 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