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
813d38e7
Commit
813d38e7
authored
Aug 07, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a test suite runner
parent
af96e515
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
0 deletions
+42
-0
test/suite.go
test/suite.go
+42
-0
No files found.
test/suite.go
0 → 100644
View file @
813d38e7
package
dstest
import
(
"reflect"
"runtime"
"testing"
dstore
"github.com/ipfs/go-datastore"
)
// BasicSubtests is a list of all basic tests.
var
BasicSubtests
=
[]
func
(
t
*
testing
.
T
,
ds
dstore
.
Datastore
){
SubtestBasicPutGet
,
SubtestNotFounds
,
SubtestManyKeysAndQuery
,
}
// BatchSubtests is a list of all basic batching datastore tests.
var
BatchSubtests
=
[]
func
(
t
*
testing
.
T
,
ds
dstore
.
Batching
){
RunBatchTest
,
RunBatchDeleteTest
,
}
func
getFunctionName
(
i
interface
{})
string
{
return
runtime
.
FuncForPC
(
reflect
.
ValueOf
(
i
)
.
Pointer
())
.
Name
()
}
// SubtestAll tests the given datastore against all the subtests.
func
SubtestAll
(
t
*
testing
.
T
,
ds
dstore
.
Datastore
)
{
for
_
,
f
:=
range
BasicSubtests
{
t
.
Run
(
getFunctionName
(
f
),
func
(
t
*
testing
.
T
)
{
f
(
t
,
ds
)
})
}
if
_
,
ok
:=
ds
.
(
dstore
.
Batching
);
ok
{
for
_
,
f
:=
range
BasicSubtests
{
t
.
Run
(
getFunctionName
(
f
),
func
(
t
*
testing
.
T
)
{
f
(
t
,
ds
)
})
}
}
}
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