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-unixfs
Commits
697625a9
Commit
697625a9
authored
10 years ago
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(util:testutil) add NewBlockOrFail(t, data) factory method
for use in tests
parent
be835662
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
util/testutil/blocks.go
util/testutil/blocks.go
+22
-0
No files found.
util/testutil/blocks.go
0 → 100644
View file @
697625a9
package
testutil
import
(
"testing"
blocks
"github.com/jbenet/go-ipfs/blocks"
)
// NewBlockOrFail returns a block created from msgData. Signals test failure if
// creation fails.
//
// NB: NewBlockOrFail accepts a msgData parameter to avoid non-determinism in
// tests. Generating random block data could potentially result in unexpected
// behavior in tests. Thus, it is left up to the caller to select the msgData
// that will determine the blocks key.
func
NewBlockOrFail
(
t
*
testing
.
T
,
msgData
string
)
blocks
.
Block
{
block
,
blockCreationErr
:=
blocks
.
NewBlock
([]
byte
(
msgData
))
if
blockCreationErr
!=
nil
{
t
.
Fatal
(
blockCreationErr
)
}
return
*
block
}
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