good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
5b3d4fae
Commit
5b3d4fae
authored
Jan 1, 2014
by
Jeffrey Wilcke
Browse files
Options
Downloads
Patches
Plain Diff
Work in progress external test runner
parent
61d67f2a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
db_query_interface.go
+9
-3
9 additions, 3 deletions
db_query_interface.go
test_runner.go
+35
-0
35 additions, 0 deletions
test_runner.go
test_runner_test.go
+31
-0
31 additions, 0 deletions
test_runner_test.go
with
75 additions
and
3 deletions
db_query_interface.go
+
9
−
3
View file @
5b3d4fae
...
...
@@ -68,12 +68,18 @@ func (i *DbInterface) ParseInput(input string) bool {
fmt
.
Println
(
hex
.
EncodeToString
([]
byte
(
i
.
trie
.
root
)))
case
"get"
:
fmt
.
Println
(
i
.
trie
.
Get
(
tokens
[
1
]))
case
"root"
:
fmt
.
Println
(
hex
.
EncodeToString
([]
byte
(
i
.
trie
.
root
)))
case
"rawroot"
:
fmt
.
Println
(
i
.
trie
.
root
)
case
"exit"
,
"quit"
,
"q"
:
return
false
case
"help"
:
fmt
.
Println
(
`query commands:
update KEY VALUE
get KEY
fmt
.
Printf
(
`QUERY COMMANDS:
update KEY VALUE - Updates/Creates a new value for the given key
get KEY - Retrieves the given key
root - Prints the hex encoded merkle root
rawroot - Prints the raw merkle root
`
)
default
:
fmt
.
Println
(
"Unknown command:"
,
tokens
[
0
])
...
...
This diff is collapsed.
Click to expand it.
test_runner.go
0 → 100644
+
35
−
0
View file @
5b3d4fae
package
main
import
(
"fmt"
"testing"
"encoding/json"
)
type
TestSource
struct
{
Inputs
map
[
string
]
string
Expectation
string
}
func
NewTestSource
(
source
string
)
*
TestSource
{
s
:=
&
TestSource
{}
err
:=
json
.
Unmarshal
([]
byte
(
source
),
s
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
}
return
s
}
type
TestRunner
struct
{
source
*
TestSource
}
func
NewTestRunner
(
t
*
testing
.
T
)
*
TestRunner
{
return
&
TestRunner
{}
}
func
(
runner
*
TestRunner
)
RunFromString
(
input
string
,
Cb
func
(
*
TestSource
))
{
source
:=
NewTestSource
(
input
)
Cb
(
source
)
}
This diff is collapsed.
Click to expand it.
test_runner_test.go
0 → 100644
+
31
−
0
View file @
5b3d4fae
package
main
import
(
_
"fmt"
"testing"
"encoding/hex"
)
var
testsource
=
`{"Inputs":{
"doe": "reindeer",
"dog": "puppy",
"dogglesworth": "cat"
},
"Expectation":"e378927bfc1bd4f01a2e8d9f59bd18db8a208bb493ac0b00f93ce51d4d2af76c"
}`
func
TestTestRunner
(
t
*
testing
.
T
)
{
db
,
_
:=
NewMemDatabase
()
trie
:=
NewTrie
(
db
,
""
)
runner
:=
NewTestRunner
(
t
)
runner
.
RunFromString
(
testsource
,
func
(
source
*
TestSource
)
{
for
key
,
value
:=
range
source
.
Inputs
{
trie
.
Update
(
key
,
value
)
}
if
hex
.
EncodeToString
([]
byte
(
trie
.
root
))
!=
source
.
Expectation
{
t
.
Error
(
"trie root did not match"
)
}
})
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment