From 93806601d1799ee2023cd6035f028e6425d02348 Mon Sep 17 00:00:00 2001 From: Christopher Buesser Date: Thu, 2 May 2019 19:30:36 -0400 Subject: [PATCH 1/2] Test Fix: nil pointer error for core.NewNode This commit fixes the errors resulting from passing a nil pointer to the core.NewNode function in TestExternalUnmmount and setupIpnsTest. In the previous nil's place a &core.BuildCfg{} is now passed. Both changes follow the same pattern: ```diff - node, err = core.NewNode(context.Background(), nil) + node, err = core.NewNode(context.Background(), &core.BuildCfg{}) ``` On branch go-test-fix Changes to be committed: modified: fuse/ipns/ipns_test.go modified: fuse/node/mount_test.go License: MIT Signed-off-by: Chris Buesser --- fuse/ipns/ipns_test.go | 2 +- fuse/node/mount_test.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fuse/ipns/ipns_test.go b/fuse/ipns/ipns_test.go index e2ff88da4cd..80ab4a52ecf 100644 --- a/fuse/ipns/ipns_test.go +++ b/fuse/ipns/ipns_test.go @@ -104,7 +104,7 @@ func setupIpnsTest(t *testing.T, node *core.IpfsNode) (*core.IpfsNode, *mountWra var err error if node == nil { - node, err = core.NewNode(context.Background(), nil) + node, err = core.NewNode(context.Background(), &core.BuildCfg{}) if err != nil { t.Fatal(err) } diff --git a/fuse/node/mount_test.go b/fuse/node/mount_test.go index ec57b9fc097..6cd2cf29911 100644 --- a/fuse/node/mount_test.go +++ b/fuse/node/mount_test.go @@ -42,7 +42,7 @@ func TestExternalUnmount(t *testing.T) { // TODO: needed? maybeSkipFuseTests(t) - node, err := core.NewNode(context.Background(), nil) + node, err := core.NewNode(context.Background(), &core.BuildCfg{}) if err != nil { t.Fatal(err) } From 5ce2deb5fc418abdd42bec61b8619b733589450f Mon Sep 17 00:00:00 2001 From: Christopher Buesser Date: Thu, 2 May 2019 19:43:46 -0400 Subject: [PATCH 2/2] Test Fix: Nil error handling In TestExternalUnmount, the Mount function is called which returns an error which can be nil. The error type is then used in a comparison where Error() is called on it. If the error is nil, this results in a panic. Added a if err != nil {} guard to make sure that Error() is not called if the value is nil On branch go-test-fix Changes to be committed: modified: fuse/node/mount_test.go License: MIT Signed-off-by: Chris Buesser --- fuse/node/mount_test.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fuse/node/mount_test.go b/fuse/node/mount_test.go index 6cd2cf29911..9c8783901ac 100644 --- a/fuse/node/mount_test.go +++ b/fuse/node/mount_test.go @@ -64,9 +64,12 @@ func TestExternalUnmount(t *testing.T) { mkdir(t, ipnsDir) err = Mount(node, ipfsDir, ipnsDir) - if strings.Contains(err.Error(), "unable to check fuse version") || err == fuse.ErrOSXFUSENotFound { - t.Skip(err) + if err != nil { + if strings.Contains(err.Error(), "unable to check fuse version") || err == fuse.ErrOSXFUSENotFound { + t.Skip(err) + } } + if err != nil { t.Fatalf("error mounting: %v", err) }