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-datastore
Commits
ae428d8d
Commit
ae428d8d
authored
Feb 10, 2020
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test: add a lookup test
This should have already been committed...
parent
bffc5fdb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
+45
-0
mount/lookup_test.go
mount/lookup_test.go
+45
-0
No files found.
mount/lookup_test.go
0 → 100644
View file @
ae428d8d
package
mount
import
(
"testing"
datastore
"github.com/ipfs/go-datastore"
)
func
TestLookup
(
t
*
testing
.
T
)
{
mapds0
:=
datastore
.
NewMapDatastore
()
mapds1
:=
datastore
.
NewMapDatastore
()
mapds2
:=
datastore
.
NewMapDatastore
()
mapds3
:=
datastore
.
NewMapDatastore
()
m
:=
New
([]
Mount
{
{
Prefix
:
datastore
.
NewKey
(
"/"
),
Datastore
:
mapds0
},
{
Prefix
:
datastore
.
NewKey
(
"/foo"
),
Datastore
:
mapds1
},
{
Prefix
:
datastore
.
NewKey
(
"/bar"
),
Datastore
:
mapds2
},
{
Prefix
:
datastore
.
NewKey
(
"/baz"
),
Datastore
:
mapds3
},
})
_
,
mnts
,
_
:=
m
.
lookupAll
(
datastore
.
NewKey
(
"/bar"
))
if
len
(
mnts
)
!=
1
||
mnts
[
0
]
!=
datastore
.
NewKey
(
"/bar"
)
{
t
.
Errorf
(
"expected to find the mountpoint /bar, got %v"
,
mnts
)
}
_
,
mnts
,
_
=
m
.
lookupAll
(
datastore
.
NewKey
(
"/fo"
))
if
len
(
mnts
)
!=
1
||
mnts
[
0
]
!=
datastore
.
NewKey
(
"/"
)
{
t
.
Errorf
(
"expected to find the mountpoint /, got %v"
,
mnts
)
}
_
,
mnt
,
_
:=
m
.
lookup
(
datastore
.
NewKey
(
"/fo"
))
if
mnt
!=
datastore
.
NewKey
(
"/"
)
{
t
.
Errorf
(
"expected to find the mountpoint /, got %v"
,
mnt
)
}
// /foo lives in /, /foo/bar lives in /foo. Most systems don't let us use the key "" or /.
_
,
mnt
,
_
=
m
.
lookup
(
datastore
.
NewKey
(
"/foo"
))
if
mnt
!=
datastore
.
NewKey
(
"/"
)
{
t
.
Errorf
(
"expected to find the mountpoint /, got %v"
,
mnt
)
}
_
,
mnt
,
_
=
m
.
lookup
(
datastore
.
NewKey
(
"/foo/bar"
))
if
mnt
!=
datastore
.
NewKey
(
"/foo"
)
{
t
.
Errorf
(
"expected to find the mountpoint /foo, got %v"
,
mnt
)
}
}
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