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
32214c5d
Unverified
Commit
32214c5d
authored
Mar 19, 2019
by
Michael Avila
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update test to account for nested mounts
parent
0ab21bf7
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
mount/mount_test.go
mount/mount_test.go
+49
-0
No files found.
mount/mount_test.go
View file @
32214c5d
...
...
@@ -297,6 +297,55 @@ func TestQueryCross(t *testing.T) {
}
}
func
TestQueryCrossWithSort
(
t
*
testing
.
T
)
{
mapds0
:=
datastore
.
NewMapDatastore
()
mapds1
:=
datastore
.
NewMapDatastore
()
mapds2
:=
datastore
.
NewMapDatastore
()
m
:=
mount
.
New
([]
mount
.
Mount
{
{
Prefix
:
datastore
.
NewKey
(
"/zoo"
),
Datastore
:
mapds1
},
{
Prefix
:
datastore
.
NewKey
(
"/boo/5"
),
Datastore
:
mapds2
},
{
Prefix
:
datastore
.
NewKey
(
"/boo"
),
Datastore
:
mapds0
},
})
m
.
Put
(
datastore
.
NewKey
(
"/zoo/0"
),
[]
byte
(
"123"
))
m
.
Put
(
datastore
.
NewKey
(
"/zoo/1"
),
[]
byte
(
"234"
))
m
.
Put
(
datastore
.
NewKey
(
"/boo/9"
),
[]
byte
(
"345"
))
m
.
Put
(
datastore
.
NewKey
(
"/boo/3"
),
[]
byte
(
"456"
))
m
.
Put
(
datastore
.
NewKey
(
"/boo/5/hello"
),
[]
byte
(
"789"
))
res
,
err
:=
m
.
Query
(
query
.
Query
{
Orders
:
[]
query
.
Order
{
query
.
OrderByKey
{}}})
if
err
!=
nil
{
t
.
Fatalf
(
"Query fail: %v
\n
"
,
err
)
}
entries
,
err
:=
res
.
Rest
()
if
err
!=
nil
{
t
.
Fatalf
(
"Query Results.Rest fail: %v
\n
"
,
err
)
}
expect
:=
[]
string
{
"/boo/3"
,
"/boo/5/hello"
,
"/boo/9"
,
"/zoo/0"
,
"/zoo/1"
,
}
if
len
(
entries
)
!=
len
(
expect
)
{
t
.
Fatalf
(
"expected %d entries, but got %d"
,
len
(
expect
),
len
(
entries
))
}
for
i
,
e
:=
range
expect
{
if
e
!=
entries
[
i
]
.
Key
{
t
.
Errorf
(
"expected key %s, but got %s"
,
e
,
entries
[
i
]
.
Key
)
}
}
err
=
res
.
Close
()
if
err
!=
nil
{
t
.
Errorf
(
"result.Close failed %d"
,
err
)
}
}
func
TestLookupPrio
(
t
*
testing
.
T
)
{
mapds0
:=
datastore
.
NewMapDatastore
()
mapds1
:=
datastore
.
NewMapDatastore
()
...
...
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