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
interface-go-dms3-core
Commits
5c6a7519
Commit
5c6a7519
authored
Mar 05, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests: add symlink target test
(also, fix some error versus fatal nits)
parent
4e99a8e9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
7 deletions
+28
-7
tests/unixfs.go
tests/unixfs.go
+28
-7
No files found.
tests/unixfs.go
View file @
5c6a7519
...
...
@@ -737,22 +737,23 @@ func (tp *provider) TestLs(t *testing.T) {
defer
cancel
()
api
,
err
:=
tp
.
makeAPI
(
ctx
)
if
err
!=
nil
{
t
.
Error
(
err
)
t
.
Fatal
(
err
)
}
r
:=
strings
.
NewReader
(
"content-of-file"
)
p
,
err
:=
api
.
Unixfs
()
.
Add
(
ctx
,
files
.
NewMapDirectory
(
map
[
string
]
files
.
Node
{
"0"
:
files
.
NewMapDirectory
(
map
[
string
]
files
.
Node
{
"name-of-file"
:
files
.
NewReaderFile
(
r
),
"name-of-symlink"
:
files
.
NewLinkFile
(
"/foo/bar"
,
nil
),
}),
}))
if
err
!=
nil
{
t
.
Error
(
err
)
t
.
Fatal
(
err
)
}
entries
,
err
:=
api
.
Unixfs
()
.
Ls
(
ctx
,
p
)
if
err
!=
nil
{
t
.
Error
(
err
)
t
.
Fatal
(
err
)
}
entry
:=
<-
entries
...
...
@@ -760,13 +761,33 @@ func (tp *provider) TestLs(t *testing.T) {
t
.
Fatal
(
entry
.
Err
)
}
if
entry
.
Size
!=
15
{
t
.
Fatal
f
(
"expected size = 15, got %d"
,
entry
.
Size
)
t
.
Error
f
(
"expected size = 15, got %d"
,
entry
.
Size
)
}
if
entry
.
Name
!=
"name-of-file"
{
t
.
Fatalf
(
"expected name = name-of-file, got %s"
,
entry
.
Name
)
t
.
Errorf
(
"expected name = name-of-file, got %s"
,
entry
.
Name
)
}
if
entry
.
Type
!=
coreiface
.
TFile
{
t
.
Errorf
(
"wrong type %s"
,
entry
.
Type
)
}
if
entry
.
Cid
.
String
()
!=
"QmX3qQVKxDGz3URVC3861Z3CKtQKGBn6ffXRBBWGMFz9Lr"
{
t
.
Fatalf
(
"expected cid = QmX3qQVKxDGz3URVC3861Z3CKtQKGBn6ffXRBBWGMFz9Lr, got %s"
,
entry
.
Cid
)
t
.
Errorf
(
"expected cid = QmX3qQVKxDGz3URVC3861Z3CKtQKGBn6ffXRBBWGMFz9Lr, got %s"
,
entry
.
Cid
)
}
entry
=
<-
entries
if
entry
.
Err
!=
nil
{
t
.
Fatal
(
entry
.
Err
)
}
if
entry
.
Type
!=
coreiface
.
TSymlink
{
t
.
Errorf
(
"wrong type %s"
,
entry
.
Type
)
}
if
entry
.
Name
!=
"name-of-symlink"
{
t
.
Errorf
(
"expected name = name-of-symlink, got %s"
,
entry
.
Name
)
}
if
entry
.
Target
.
String
()
!=
"/foo/bar"
{
t
.
Errorf
(
"expected symlink target to be /foo/bar, got %s"
,
entry
.
Target
)
}
if
int
(
entry
.
Size
)
!=
len
(
entry
.
Target
.
String
())
{
t
.
Errorf
(
"expected size = %d, got %d"
,
len
(
entry
.
Target
.
String
()),
entry
.
Size
)
}
if
l
,
ok
:=
<-
entries
;
ok
{
t
.
Errorf
(
"didn't expect a second link"
)
...
...
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