@cryptotaxi247 / kubo / commits / aca6f61a6

path: fix tests

This commit was moved from ipfs/interface-go-ipfs-core@33d445a6140b26da90a07d2bf86c8827d74284b6 This commit was moved from ipfs/boxo@1497150b1f90816ac7b117fbe0b2fb6aacaa7968

Łukasz Magiera committed Mar 25, 2019 at 17:03 UTC aca6f61a63b790c779744a6cca8d058ac6388973
5 files changed +9 -45
core/coreiface/tests/block.go
+1 -4
@@ -110,10 +110,7 @@ func (tp *provider) TestBlockGet(t *testing.T) {
110 t.Error("didn't get correct data back")
111 }
112
113 - p, err := coreiface.ParsePath("/ipfs/" + res.Path().Cid().String())
114 - if err != nil {
115 - t.Fatal(err)
116 - }
113 + p := coreiface.ParsePath("/ipfs/" + res.Path().Cid().String())
114
115 rp, err := api.ResolvePath(ctx, p)
116 if err != nil {
core/coreiface/tests/dag.go
+1 -4
@@ -113,10 +113,7 @@ func (tp *provider) TestDagPath(t *testing.T) {
113 t.Fatal(err)
114 }
115
116 - p, err := coreiface.ParsePath(path.Join(nd.Cid().String(), "lnk"))
117 - if err != nil {
118 - t.Fatal(err)
119 - }
116 + p := coreiface.ParsePath(path.Join(nd.Cid().String(), "lnk"))
117
118 rp, err := api.ResolvePath(ctx, p)
119 if err != nil {
core/coreiface/tests/name.go
+1 -5
@@ -35,11 +35,7 @@ func addTestObject(ctx context.Context, api coreiface.CoreAPI) (coreiface.Path,
35 }
36
37 func appendPath(p coreiface.Path, sub string) coreiface.Path {
38 - p, err := coreiface.ParsePath(path.Join(p.String(), sub))
39 - if err != nil {
40 - panic(err)
41 - }
42 - return p
38 + return coreiface.ParsePath(path.Join(p.String(), sub))
39 }
40
41 func (tp *provider) TestPublishResolve(t *testing.T) {
core/coreiface/tests/path.go
+5 -28
@@ -75,12 +75,7 @@ func (tp *provider) TestPathRemainder(t *testing.T) {
75 t.Fatal(err)
76 }
77
78 - p1, err := coreiface.ParsePath(nd.String() + "/foo/bar")
79 - if err != nil {
80 - t.Fatal(err)
81 - }
82 -
83 - rp1, err := api.ResolvePath(ctx, p1)
78 + rp1, err := api.ResolvePath(ctx, coreiface.ParsePath(nd.String()+"/foo/bar"))
79 if err != nil {
80 t.Fatal(err)
81 }
@@ -111,12 +106,7 @@ func (tp *provider) TestEmptyPathRemainder(t *testing.T) {
106 t.Fatal(err)
107 }
108
114 - p1, err := coreiface.ParsePath(nd.Cid().String())
115 - if err != nil {
116 - t.Fatal(err)
117 - }
118 -
119 - rp1, err := api.ResolvePath(ctx, p1)
109 + rp1, err := api.ResolvePath(ctx, coreiface.ParsePath(nd.Cid().String()))
110 if err != nil {
111 t.Fatal(err)
112 }
@@ -147,12 +137,7 @@ func (tp *provider) TestInvalidPathRemainder(t *testing.T) {
137 t.Fatal(err)
138 }
139
150 - p1, err := coreiface.ParsePath("/ipld/" + nd.Cid().String() + "/bar/baz")
151 - if err != nil {
152 - t.Fatal(err)
153 - }
154 -
155 - _, err = api.ResolvePath(ctx, p1)
140 + _, err = api.ResolvePath(ctx, coreiface.ParsePath("/ipld/"+nd.Cid().String()+"/bar/baz"))
141 if err == nil || !strings.Contains(err.Error(), "no such link found") {
142 t.Fatalf("unexpected error: %s", err)
143 }
@@ -188,12 +173,7 @@ func (tp *provider) TestPathRoot(t *testing.T) {
173 t.Fatal(err)
174 }
175
191 - p1, err := coreiface.ParsePath("/ipld/" + nd.Cid().String() + "/foo")
192 - if err != nil {
193 - t.Fatal(err)
194 - }
195 -
196 - rp, err := api.ResolvePath(ctx, p1)
176 + rp, err := api.ResolvePath(ctx, coreiface.ParsePath("/ipld/"+nd.Cid().String()+"/foo"))
177 if err != nil {
178 t.Fatal(err)
179 }
@@ -208,10 +188,7 @@ func (tp *provider) TestPathRoot(t *testing.T) {
188 }
189
190 func (tp *provider) TestPathJoin(t *testing.T) {
211 - p1, err := coreiface.ParsePath("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz")
212 - if err != nil {
213 - t.Fatal(err)
214 - }
191 + p1 := coreiface.ParsePath("/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz")
192
193 if coreiface.Join(p1, "foo").String() != "/ipfs/QmYNmQKp6SuaVrpgWRsPTgCQCnpxUYGq76YEKBXuj2N4H6/bar/baz/foo" {
194 t.Error("unexpected path")
core/coreiface/tests/unixfs.go
+1 -4
@@ -592,10 +592,7 @@ func (tp *provider) TestGetEmptyFile(t *testing.T) {
592 t.Fatal(err)
593 }
594
595 - emptyFilePath, err := coreiface.ParsePath(emptyFile)
596 - if err != nil {
597 - t.Fatal(err)
598 - }
595 + emptyFilePath := coreiface.ParsePath(emptyFile)
596
597 r, err := api.Unixfs().Get(ctx, emptyFilePath)
598 if err != nil {