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
0c7ff7b0
Commit
0c7ff7b0
authored
Oct 04, 2014
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add skeleton for ipns test, to be finished when there is a mock core.IpfsNode
parent
02de5222
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
62 additions
and
0 deletions
+62
-0
fuse/ipns/ipns_test.go
fuse/ipns/ipns_test.go
+62
-0
No files found.
fuse/ipns/ipns_test.go
0 → 100644
View file @
0c7ff7b0
package
ipns
import
(
"crypto/rand"
"os"
"testing"
fstest
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/bazil.org/fuse/fs/fstestutil"
)
func
randBytes
(
size
int
)
[]
byte
{
b
:=
make
([]
byte
,
size
)
rand
.
Read
(
b
)
return
b
}
func
TestIpnsBasicIO
(
t
*
testing
.
T
)
{
fs
,
err
:=
NewIpns
(
nil
,
""
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
mnt
,
err
:=
fstest
.
MountedT
(
t
,
fs
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
data
:=
randBytes
(
12345
)
fi
,
err
:=
os
.
Create
(
mnt
.
Dir
+
"/local/testfile"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
n
,
err
:=
fi
.
Write
(
data
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
n
!=
len
(
data
)
{
t
.
Fatal
(
"Didnt write proper amount!"
)
}
fi
.
Close
()
//TODO: maybe wait for the publish to happen? or not, should test both cases
fi
,
err
=
os
.
Open
(
mnt
.
Dir
+
"/local/testfile"
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
rbuf
:=
make
([]
byte
,
len
(
data
))
n
,
err
=
fi
.
Read
(
rbuf
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
n
!=
len
(
rbuf
)
{
t
.
Fatal
(
"Failed to read correct amount!"
)
}
fi
.
Close
()
}
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