aboutsummaryrefslogtreecommitdiffstats
path: root/utils
diff options
context:
space:
mode:
authorAlberto Cortés <alcortesm@gmail.com>2017-02-13 16:04:41 +0100
committerGitHub <noreply@github.com>2017-02-13 16:04:41 +0100
commitd08446c5ad1c3523f1ba05255e38b9eda395408e (patch)
tree59a85ca0484f3c6a7c07a8bd6bfa8d0ef27a5cc0 /utils
parent1fdfe887278bf1e6039215fa5f48e5b497c20bee (diff)
downloadgo-git-d08446c5ad1c3523f1ba05255e38b9eda395408e.tar.gz
simplify noder mocks in test (#265)
Diffstat (limited to 'utils')
-rw-r--r--utils/merkletrie/internal/frame/frame_test.go11
-rw-r--r--utils/merkletrie/iter_test.go11
2 files changed, 4 insertions, 18 deletions
diff --git a/utils/merkletrie/internal/frame/frame_test.go b/utils/merkletrie/internal/frame/frame_test.go
index 9cc0994..516d78b 100644
--- a/utils/merkletrie/internal/frame/frame_test.go
+++ b/utils/merkletrie/internal/frame/frame_test.go
@@ -89,20 +89,13 @@ func checkFirstAndDrop(c *C, f *Frame, expectedNodeName string, expectedOK bool)
}
// a mock noder that returns error when Children() is called
-type errorNoder struct{}
+type errorNoder struct{ noder.Noder }
-func (e *errorNoder) Hash() []byte { return nil }
-func (e *errorNoder) Name() string { return "" }
-func (e *errorNoder) String() string { return "" }
-func (e *errorNoder) IsDir() bool { return true }
func (e *errorNoder) Children() ([]noder.Noder, error) {
return nil, fmt.Errorf("mock error")
}
-func (e *errorNoder) NumChildren() (int, error) {
- return 0, fmt.Errorf("mock error")
-}
func (s *FrameSuite) TestNewFrameErrors(c *C) {
_, err := New(&errorNoder{})
- c.Assert(err, Not(IsNil))
+ c.Assert(err, ErrorMatches, "mock error")
}
diff --git a/utils/merkletrie/iter_test.go b/utils/merkletrie/iter_test.go
index c1900da..fa7c5f5 100644
--- a/utils/merkletrie/iter_test.go
+++ b/utils/merkletrie/iter_test.go
@@ -440,20 +440,13 @@ func find(c *C, tree noder.Noder, name string) noder.Path {
}
}
-type errorNoder struct{}
+type errorNoder struct{ noder.Noder }
-func (e *errorNoder) Name() string { return "" }
-func (e *errorNoder) String() string { return "" }
-func (e *errorNoder) Hash() []byte { return nil }
-func (e *errorNoder) IsDir() bool { return true }
func (e *errorNoder) Children() ([]noder.Noder, error) {
return nil, fmt.Errorf("mock error")
}
-func (e *errorNoder) NumChildren() (int, error) {
- return 0, fmt.Errorf("mock error")
-}
func (s *IterSuite) TestNewIterFailsOnChildrenErrors(c *C) {
_, err := merkletrie.NewIter(&errorNoder{})
- c.Assert(err, Not(IsNil))
+ c.Assert(err, ErrorMatches, "mock error")
}