@cryptotaxi247 / kubo / commits / d96246c62

Fixed tests to actually test for the error we are seeking

Cleaned the tests, and actually test for the error.

Travis Person committed May 20, 2015 at 21:56 UTC d96246c6223021f55049a8714bda70466f47bd24
1 file changed +6 -26
core/pathresolver_test.go
+6 -26
@@ -3,39 +3,19 @@ package core
3 import (
4 "testing"
5
6 - context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
7 - config "github.com/ipfs/go-ipfs/repo/config"
8 - "github.com/ipfs/go-ipfs/util/testutil"
9 - "github.com/ipfs/go-ipfs/repo"
6 path "github.com/ipfs/go-ipfs/path"
7 + "strings"
8 )
9
10 func TestResolveInvalidPath(t *testing.T) {
14 - ctx := context.TODO()
15 - id := testIdentity
16 -
17 - r := &repo.Mock{
18 - C: config.Config{
19 - Identity: id,
20 - Datastore: config.Datastore{
21 - Type: "memory",
22 - },
23 - Addresses: config.Addresses{
24 - Swarm: []string{"/ip4/0.0.0.0/tcp/4001"},
25 - API: "/ip4/127.0.0.1/tcp/8000",
26 - },
27 - },
28 - D: testutil.ThreadSafeCloserMapDatastore(),
29 - }
30 -
31 - n, err := NewIPFSNode(ctx, Standard(r, false))
11 + n, err := NewMockNode()
12 if n == nil || err != nil {
33 - t.Error("Should have constructed.", err)
13 + t.Fatal("Should have constructed.", err)
14 }
15
36 - _, err = Resolve(ctx, n, path.Path("/ipfs/"))
37 - if err == nil {
38 - t.Error("Should get invalid path")
16 + _, err = Resolve(n.Context(), n, path.Path("/ipfs/"))
17 + if !strings.HasPrefix(err.Error(), "invalid path") {
18 + t.Fatal("Should get invalid path.", err)
19 }
20
21 }