Skip to content

Commit

Permalink
Merge pull request #3840 from ipfs/fix/test/fuse
Browse files Browse the repository at this point in the history
test: fix fuse tests, they were broken some time ago
  • Loading branch information
whyrusleeping authored Mar 30, 2017
2 parents 987ff1a + ea838a0 commit 39f89c8
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions fuse/readonly/ipfs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
ci "github.com/ipfs/go-ipfs/thirdparty/testutil/ci"
uio "github.com/ipfs/go-ipfs/unixfs/io"

cid "gx/ipfs/QmV5gPoRsjN1Gid3LMdNZTyfCtP2DsvqEbMAmz82RmmiGk/go-cid"
node "gx/ipfs/QmYDscK7dmdo2GZ9aumS8s5auUUAH5mR1jvj5pYhWusfK7/go-ipld-node"
u "gx/ipfs/QmZuY8aV7zbNXVy6DyN9SmnuH3o9nG852F4aTiSBpts8d1/go-ipfs-util"
fstest "gx/ipfs/QmaFNtBAXX4nVMQWbUqNysXyhevUj1k4B1y5uS45LC7Vw9/fuse/fs/fstestutil"
Expand Down Expand Up @@ -117,7 +116,7 @@ func TestIpfsStressRead(t *testing.T) {
nd, mnt := setupIpfsTest(t, nil)
defer mnt.Close()

var ks []*cid.Cid
var nodes []node.Node
var paths []string

nobj := 50
Expand All @@ -126,29 +125,33 @@ func TestIpfsStressRead(t *testing.T) {
// Make a bunch of objects
for i := 0; i < nobj; i++ {
fi, _ := randObj(t, nd, rand.Int63n(50000))
c := fi.Cid()
ks = append(ks, c)
paths = append(paths, c.String())
nodes = append(nodes, fi)
paths = append(paths, fi.Cid().String())
}

// Now make a bunch of dirs
for i := 0; i < ndiriter; i++ {
db := uio.NewDirectory(nd.DAG)
for j := 0; j < 1+rand.Intn(10); j++ {
name := fmt.Sprintf("child%d", j)
err := db.AddChild(nd.Context(), name, ks[rand.Intn(len(ks))])

err := db.AddChild(nd.Context(), name, nodes[rand.Intn(len(nodes))])
if err != nil {
t.Fatal(err)
}
}
newdir := db.GetNode()
k, err := nd.DAG.Add(newdir)
newdir, err := db.GetNode()
if err != nil {
t.Fatal(err)
}

_, err = nd.DAG.Add(newdir)
if err != nil {
t.Fatal(err)
}

ks = append(ks, k)
npaths := getPaths(t, nd, k.String(), newdir)
nodes = append(nodes, newdir)
npaths := getPaths(t, nd, newdir.Cid().String(), newdir.(*dag.ProtoNode))
paths = append(paths, npaths...)
}

Expand Down Expand Up @@ -208,16 +211,19 @@ func TestIpfsBasicDirRead(t *testing.T) {

// Make a 'file'
fi, data := randObj(t, nd, 10000)
k := fi.Cid()

// Make a directory and put that file in it
db := uio.NewDirectory(nd.DAG)
err := db.AddChild(nd.Context(), "actual", k)
err := db.AddChild(nd.Context(), "actual", fi)
if err != nil {
t.Fatal(err)
}

d1nd, err := db.GetNode()
if err != nil {
t.Fatal(err)
}

d1nd := db.GetNode()
d1ndk, err := nd.DAG.Add(d1nd)
if err != nil {
t.Fatal(err)
Expand Down

0 comments on commit 39f89c8

Please sign in to comment.