Commit 4a78a972 authored by Jeromy's avatar Jeromy Committed by Juan Batiz-Benet

remove testing imports from non testing code

rename bserv mock to mock_test

swap out testing.T for an interface
parent f39af41a
package blockservice
import (
"testing"
bitswap "github.com/ipfs/go-ipfs/exchange/bitswap"
tn "github.com/ipfs/go-ipfs/exchange/bitswap/testnet"
mockrouting "github.com/ipfs/go-ipfs/routing/mock"
delay "github.com/ipfs/go-ipfs/thirdparty/delay"
)
type fataler interface {
Fatal(args ...interface{})
}
// Mocks returns |n| connected mock Blockservices
func Mocks(t *testing.T, n int) []*BlockService {
func Mocks(t fataler, n int) []*BlockService {
net := tn.VirtualNetwork(mockrouting.NewServer(), delay.Fixed(0))
sg := bitswap.NewTestSessionGenerator(net)
......
package core
package coremock
import (
ctxgroup "github.com/ipfs/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-ctxgroup"
......@@ -7,6 +7,7 @@ import (
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
"github.com/ipfs/go-ipfs/blocks/blockstore"
blockservice "github.com/ipfs/go-ipfs/blockservice"
core "github.com/ipfs/go-ipfs/core"
"github.com/ipfs/go-ipfs/exchange/offline"
mdag "github.com/ipfs/go-ipfs/merkledag"
nsys "github.com/ipfs/go-ipfs/namesys"
......@@ -25,9 +26,9 @@ import (
// Additionally, the context group isn't wired up. This is as good as broken.
// NewMockNode constructs an IpfsNode for use in tests.
func NewMockNode() (*IpfsNode, error) {
func NewMockNode() (*core.IpfsNode, error) {
ctx := context.TODO()
nd := new(IpfsNode)
nd := new(core.IpfsNode)
// Generate Identity
ident, err := testutil.RandIdentity()
......
package core
package core_test
import (
"testing"
core "github.com/ipfs/go-ipfs/core"
coremock "github.com/ipfs/go-ipfs/core/mock"
path "github.com/ipfs/go-ipfs/path"
)
func TestResolveNoComponents(t *testing.T) {
n, err := NewMockNode()
n, err := coremock.NewMockNode()
if n == nil || err != nil {
t.Fatal("Should have constructed a mock node", err)
}
_, err = Resolve(n.Context(), n, path.Path("/ipns/"))
_, err = core.Resolve(n.Context(), n, path.Path("/ipns/"))
if err != path.ErrNoComponents {
t.Fatal("Should error with no components (/ipns/).", err)
}
_, err = Resolve(n.Context(), n, path.Path("/ipfs/"))
_, err = core.Resolve(n.Context(), n, path.Path("/ipfs/"))
if err != path.ErrNoComponents {
t.Fatal("Should error with no components (/ipfs/).", err)
}
......
......@@ -17,6 +17,7 @@ import (
context "github.com/ipfs/go-ipfs/Godeps/_workspace/src/golang.org/x/net/context"
core "github.com/ipfs/go-ipfs/core"
coremock "github.com/ipfs/go-ipfs/core/mock"
nsfs "github.com/ipfs/go-ipfs/ipnsfs"
ci "github.com/ipfs/go-ipfs/util/testutil/ci"
)
......@@ -114,7 +115,7 @@ func setupIpnsTest(t *testing.T, node *core.IpfsNode) (*core.IpfsNode, *fstest.M
var err error
if node == nil {
node, err = core.NewMockNode()
node, err = coremock.NewMockNode()
if err != nil {
t.Fatal(err)
}
......
......@@ -16,6 +16,7 @@ import (
core "github.com/ipfs/go-ipfs/core"
coreunix "github.com/ipfs/go-ipfs/core/coreunix"
coremock "github.com/ipfs/go-ipfs/core/mock"
importer "github.com/ipfs/go-ipfs/importer"
chunk "github.com/ipfs/go-ipfs/importer/chunk"
dag "github.com/ipfs/go-ipfs/merkledag"
......@@ -47,7 +48,7 @@ func setupIpfsTest(t *testing.T, node *core.IpfsNode) (*core.IpfsNode, *fstest.M
var err error
if node == nil {
node, err = core.NewMockNode()
node, err = coremock.NewMockNode()
if err != nil {
t.Fatal(err)
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment