test: fix fuse tests, they were broken some time ago
They wouldn't compile License: MIT Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
Jakub Sztandera committed
Mar 28, 2017 at 17:15 UTC
ea838a0902d4a3f66b860443f151ef16e1a43996
1 file changed
+19
-13
fuse/readonly/ipfs_test.go
+19
-13
@@ -22,7 +22,6 @@ import (
22
ci "github.com/ipfs/go-ipfs/thirdparty/testutil/ci"
23
uio "github.com/ipfs/go-ipfs/unixfs/io"
24
25
- cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid"
25
node "gx/ipfs/QmYDscK7dmdo2GZ9aumS8s5auUUAH5mR1jvj5pYhWusfK7/go-ipld-node"
26
u "gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util"
27
fstest "gx/ipfs/QmaFNtBAXX4nVMQWbUqNysXyhevUj1k4B1y5uS45LC7Vw9/fuse/fs/fstestutil"
@@ -117,7 +116,7 @@ func TestIpfsStressRead(t *testing.T) {
116
nd, mnt := setupIpfsTest(t, nil)
117
defer mnt.Close()
118
120
- var ks []*cid.Cid
119
+ var nodes []node.Node
120
var paths []string
121
122
nobj := 50
@@ -126,9 +125,8 @@ func TestIpfsStressRead(t *testing.T) {
125
// Make a bunch of objects
126
for i := 0; i < nobj; i++ {
127
fi, _ := randObj(t, nd, rand.Int63n(50000))
129
- c := fi.Cid()
130
- ks = append(ks, c)
131
- paths = append(paths, c.String())
128
+ nodes = append(nodes, fi)
129
+ paths = append(paths, fi.Cid().String())
130
}
131
132
// Now make a bunch of dirs
@@ -136,19 +134,24 @@ func TestIpfsStressRead(t *testing.T) {
134
db := uio.NewDirectory(nd.DAG)
135
for j := 0; j < 1+rand.Intn(10); j++ {
136
name := fmt.Sprintf("child%d", j)
139
- err := db.AddChild(nd.Context(), name, ks[rand.Intn(len(ks))])
137
+
138
+ err := db.AddChild(nd.Context(), name, nodes[rand.Intn(len(nodes))])
139
if err != nil {
140
t.Fatal(err)
141
}
142
}
144
- newdir := db.GetNode()
145
- k, err := nd.DAG.Add(newdir)
143
+ newdir, err := db.GetNode()
144
+ if err != nil {
145
+ t.Fatal(err)
146
+ }
147
+
148
+ _, err = nd.DAG.Add(newdir)
149
if err != nil {
150
t.Fatal(err)
151
}
152
150
- ks = append(ks, k)
151
- npaths := getPaths(t, nd, k.String(), newdir)
153
+ nodes = append(nodes, newdir)
154
+ npaths := getPaths(t, nd, newdir.Cid().String(), newdir.(*dag.ProtoNode))
155
paths = append(paths, npaths...)
156
}
157
@@ -208,16 +211,19 @@ func TestIpfsBasicDirRead(t *testing.T) {
211
212
// Make a 'file'
213
fi, data := randObj(t, nd, 10000)
211
- k := fi.Cid()
214
215
// Make a directory and put that file in it
216
db := uio.NewDirectory(nd.DAG)
215
- err := db.AddChild(nd.Context(), "actual", k)
217
+ err := db.AddChild(nd.Context(), "actual", fi)
218
+ if err != nil {
219
+ t.Fatal(err)
220
+ }
221
+
222
+ d1nd, err := db.GetNode()
223
if err != nil {
224
t.Fatal(err)
225
}
226
220
- d1nd := db.GetNode()
227
d1ndk, err := nd.DAG.Add(d1nd)
228
if err != nil {
229
t.Fatal(err)