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
c56e720d
Unverified
Commit
c56e720d
authored
8 years ago
by
Jakub Sztandera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: reach 80% coverage of unixfs/mod
License: MIT Signed-off-by:
Jakub Sztandera
<
kubuxu@protonmail.ch
>
parent
9f9ca6cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
0 deletions
+35
-0
unixfs/mod/dagmodifier_test.go
unixfs/mod/dagmodifier_test.go
+35
-0
No files found.
unixfs/mod/dagmodifier_test.go
View file @
c56e720d
...
...
@@ -644,6 +644,10 @@ func TestReadAndSeek(t *testing.T) {
writeBuf := []byte{0, 1, 2, 3, 4, 5, 6, 7}
dagmod.Write(writeBuf)
if !dagmod.HasChanges() {
t.Fatal("there are changes, this should be true")
}
readBuf := make([]byte, 4)
offset, err := dagmod.Seek(0, os.SEEK_SET)
if offset != 0 {
...
...
@@ -693,6 +697,37 @@ func TestReadAndSeek(t *testing.T) {
}
func TestCtxRead(t *testing.T) {
dserv := getMockDagServ(t)
_, n := getNode(t, dserv, 0)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
dagmod, err := NewDagModifier(ctx, n, dserv, sizeSplitterGen(512))
if err != nil {
t.Fatal(err)
}
_, err = dagmod.Write([]byte{0, 1, 2, 3, 4, 5, 6, 7})
if err != nil {
t.Fatal(err)
}
dagmod.Seek(0, os.SEEK_SET)
readBuf := make([]byte, 4)
_, err = dagmod.CtxReadFull(ctx, readBuf)
if err != nil {
t.Fatal(err)
}
err = arrComp(readBuf, []byte{0, 1, 2, 3})
if err != nil {
t.Fatal(err)
}
// TODO(Kubuxu): context cancel case, I will do it after I figure out dagreader tests,
// because this is exacelly the same.
}
func BenchmarkDagmodWrite(b *testing.B) {
b.StopTimer()
dserv := getMockDagServ(b)
...
...
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