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
68a77964
Unverified
Commit
68a77964
authored
Nov 22, 2019
by
Michael Muré
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
query: add tests for ReturnSizes
parent
b089db1e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
1 deletion
+8
-1
test/basic_tests.go
test/basic_tests.go
+7
-1
test/suite.go
test/suite.go
+1
-0
No files found.
test/basic_tests.go
View file @
68a77964
...
@@ -301,6 +301,10 @@ func SubtestFilter(t *testing.T, ds dstore.Datastore) {
...
@@ -301,6 +301,10 @@ func SubtestFilter(t *testing.T, ds dstore.Datastore) {
test
(
new
(
testFilter
))
test
(
new
(
testFilter
))
}
}
func
SubtestReturnSizes
(
t
*
testing
.
T
,
ds
dstore
.
Datastore
)
{
subtestQuery
(
t
,
ds
,
dsq
.
Query
{
ReturnsSizes
:
true
},
100
)
}
func
randValue
()
[]
byte
{
func
randValue
()
[]
byte
{
value
:=
make
([]
byte
,
64
)
value
:=
make
([]
byte
,
64
)
rand
.
Read
(
value
)
rand
.
Read
(
value
)
...
@@ -376,7 +380,9 @@ func subtestQuery(t *testing.T, ds dstore.Datastore, q dsq.Query, count int) {
...
@@ -376,7 +380,9 @@ func subtestQuery(t *testing.T, ds dstore.Datastore, q dsq.Query, count int) {
if
!
q
.
KeysOnly
&&
!
bytes
.
Equal
(
actual
[
i
]
.
Value
,
expected
[
i
]
.
Value
)
{
if
!
q
.
KeysOnly
&&
!
bytes
.
Equal
(
actual
[
i
]
.
Value
,
expected
[
i
]
.
Value
)
{
t
.
Errorf
(
"value mismatch for result %d (key=%q)"
,
i
,
expected
[
i
]
.
Key
)
t
.
Errorf
(
"value mismatch for result %d (key=%q)"
,
i
,
expected
[
i
]
.
Key
)
}
}
if
q
.
ReturnsSizes
&&
actual
[
i
]
.
Size
<=
0
{
t
.
Errorf
(
"for result %d, expected size > 0 with ReturnsSizes"
,
i
)
}
}
}
t
.
Log
(
"deleting all keys"
)
t
.
Log
(
"deleting all keys"
)
...
...
test/suite.go
View file @
68a77964
...
@@ -18,6 +18,7 @@ var BasicSubtests = []func(t *testing.T, ds dstore.Datastore){
...
@@ -18,6 +18,7 @@ var BasicSubtests = []func(t *testing.T, ds dstore.Datastore){
SubtestLimit
,
SubtestLimit
,
SubtestFilter
,
SubtestFilter
,
SubtestManyKeysAndQuery
,
SubtestManyKeysAndQuery
,
SubtestReturnSizes
,
}
}
// BatchSubtests is a list of all basic batching datastore tests.
// BatchSubtests is a list of all basic batching datastore tests.
...
...
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