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
b8e7d934
Unverified
Commit
b8e7d934
authored
Feb 15, 2020
by
Steven Allen
Committed by
GitHub
Feb 15, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #151 from ipfs/feat/set-count
test suite: Add ElemCount to control how many elements are added.
parents
d099e8e2
d72bbd32
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
20 deletions
+31
-20
test/basic_tests.go
test/basic_tests.go
+31
-20
No files found.
test/basic_tests.go
View file @
b8e7d934
...
...
@@ -12,6 +12,17 @@ import (
dsq
"github.com/ipfs/go-datastore/query"
)
// ElemCount sets with how many elements the datastore suit
// tests are usually run with. Best to set to round numbers like
// 20, 30, 40... and at least to 20.
var
ElemCount
=
100
func
TestElemCount
(
t
*
testing
.
T
)
{
if
ElemCount
<
20
{
t
.
Fatal
(
"ElemCount should be set to 20 at least"
)
}
}
func
SubtestBasicPutGet
(
t
*
testing
.
T
,
ds
dstore
.
Datastore
)
{
k
:=
dstore
.
NewKey
(
"foo"
)
val
:=
[]
byte
(
"Hello Datastore!"
)
...
...
@@ -132,20 +143,20 @@ func SubtestLimit(t *testing.T, ds dstore.Datastore) {
Offset
:
offset
,
Limit
:
limit
,
KeysOnly
:
true
,
},
100
)
},
ElemCount
)
})
}
test
(
0
,
10
)
test
(
0
,
ElemCount
/
10
)
test
(
0
,
0
)
test
(
10
,
0
)
test
(
10
,
10
)
test
(
10
,
20
)
test
(
50
,
20
)
test
(
99
,
20
)
test
(
200
,
20
)
test
(
200
,
0
)
test
(
99
,
0
)
test
(
9
5
,
0
)
test
(
ElemCount
/
10
,
0
)
test
(
ElemCount
/
10
,
ElemCount
/
10
)
test
(
ElemCount
/
10
,
ElemCount
/
5
)
test
(
ElemCount
/
2
,
ElemCount
/
5
)
test
(
ElemCount
-
1
,
ElemCount
/
5
)
test
(
ElemCount
*
2
,
ElemCount
/
5
)
test
(
ElemCount
*
2
,
0
)
test
(
ElemCount
-
1
,
0
)
test
(
ElemCount
-
5
,
0
)
}
func
SubtestOrder
(
t
*
testing
.
T
,
ds
dstore
.
Datastore
)
{
...
...
@@ -158,7 +169,7 @@ func SubtestOrder(t *testing.T, ds dstore.Datastore) {
t
.
Run
(
name
,
func
(
t
*
testing
.
T
)
{
subtestQuery
(
t
,
ds
,
dsq
.
Query
{
Orders
:
orders
,
},
100
)
},
ElemCount
)
})
}
test
(
dsq
.
OrderByKey
{})
...
...
@@ -173,7 +184,7 @@ func SubtestOrder(t *testing.T, ds dstore.Datastore) {
}
func
SubtestManyKeysAndQuery
(
t
*
testing
.
T
,
ds
dstore
.
Datastore
)
{
subtestQuery
(
t
,
ds
,
dsq
.
Query
{
KeysOnly
:
true
},
100
)
subtestQuery
(
t
,
ds
,
dsq
.
Query
{
KeysOnly
:
true
},
ElemCount
)
}
func
SubtestBasicSync
(
t
*
testing
.
T
,
ds
dstore
.
Datastore
)
{
...
...
@@ -217,15 +228,15 @@ func (testFilter) Filter(e dsq.Entry) bool {
func
SubtestCombinations
(
t
*
testing
.
T
,
ds
dstore
.
Datastore
)
{
offsets
:=
[]
int
{
0
,
10
,
9
5
,
100
,
ElemCount
/
10
,
ElemCount
-
5
,
ElemCount
,
}
limits
:=
[]
int
{
0
,
1
,
10
,
100
,
ElemCount
/
10
,
ElemCount
,
}
filters
:=
[][]
dsq
.
Filter
{
{
dsq
.
FilterKeyCompare
{
...
...
@@ -251,7 +262,7 @@ func SubtestCombinations(t *testing.T, ds dstore.Datastore) {
lengths
:=
[]
int
{
0
,
1
,
1
0
0
,
ElemCount
/
10
,
}
perms
(
func
(
perm
[]
int
)
{
...
...
@@ -347,7 +358,7 @@ func SubtestPrefix(t *testing.T, ds dstore.Datastore) {
t
.
Run
(
prefix
,
func
(
t
*
testing
.
T
)
{
subtestQuery
(
t
,
ds
,
dsq
.
Query
{
Prefix
:
prefix
,
},
100
)
},
ElemCount
)
})
}
test
(
""
)
...
...
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