Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
4a78a972
Commit
4a78a972
authored
9 years ago
by
Jeromy
Committed by
Juan Batiz-Benet
9 years ago
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove testing imports from non testing code
rename bserv mock to mock_test swap out testing.T for an interface
parent
f39af41a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
19 additions
and
12 deletions
+19
-12
blockservice/mock.go
blockservice/mock.go
+5
-3
core/mock/mock.go
core/mock/mock.go
+4
-3
core/pathresolver_test.go
core/pathresolver_test.go
+6
-4
fuse/ipns/ipns_test.go
fuse/ipns/ipns_test.go
+2
-1
fuse/readonly/ipfs_test.go
fuse/readonly/ipfs_test.go
+2
-1
No files found.
blockservice/mock.go
View file @
4a78a972
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
)
...
...
This diff is collapsed.
Click to expand it.
core/mock.go
→
core/mock
/mock
.go
View file @
4a78a972
package
core
package
core
mock
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
()
...
...
This diff is collapsed.
Click to expand it.
core/pathresolver_test.go
View file @
4a78a972
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
)
}
...
...
This diff is collapsed.
Click to expand it.
fuse/ipns/ipns_test.go
View file @
4a78a972
...
...
@@ -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
=
core
mock
.
NewMockNode
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
This diff is collapsed.
Click to expand it.
fuse/readonly/ipfs_test.go
View file @
4a78a972
...
...
@@ -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
=
core
mock
.
NewMockNode
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment