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-dms3
Commits
8061117e
Commit
8061117e
authored
Dec 20, 2017
by
keks
Committed by
Jeromy
Jan 21, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core/commands: add TestROCommands
License: MIT Signed-off-by:
keks
<
keks@cryptoscope.co
>
parent
aec44bc4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
0 deletions
+51
-0
core/commands/commands_test.go
core/commands/commands_test.go
+51
-0
No files found.
core/commands/commands_test.go
View file @
8061117e
...
...
@@ -15,6 +15,57 @@ func collectPaths(prefix string, cmd *cmds.Command, out map[string]struct{}) {
}
}
func
TestROCommands
(
t
*
testing
.
T
)
{
list
:=
[]
string
{
"/block"
,
"/block/get"
,
"/block/stat"
,
"/cat"
,
"/commands"
,
"/dag"
,
"/dag/get"
,
"/dag/resolve"
,
"/dns"
,
"/get"
,
"/ls"
,
"/name"
,
"/name/resolve"
,
"/object"
,
"/object/data"
,
"/object/get"
,
"/object/links"
,
"/object/stat"
,
"/refs"
,
"/resolve"
,
"/version"
,
}
cmdSet
:=
make
(
map
[
string
]
struct
{})
collectPaths
(
""
,
RootRO
,
cmdSet
)
for
_
,
path
:=
range
list
{
if
_
,
ok
:=
cmdSet
[
path
];
!
ok
{
t
.
Errorf
(
"%q not in result"
,
path
)
}
else
{
delete
(
cmdSet
,
path
)
}
}
for
path
:=
range
cmdSet
{
t
.
Errorf
(
"%q in result but shouldn't be"
,
path
)
}
for
_
,
path
:=
range
list
{
path
=
path
[
1
:
]
// remove leading slash
split
:=
strings
.
Split
(
path
,
"/"
)
sub
,
err
:=
RootRO
.
Get
(
split
)
if
err
!=
nil
{
t
.
Errorf
(
"error getting subcommand %q: %v"
,
path
,
err
)
}
else
if
sub
==
nil
{
t
.
Errorf
(
"subcommand %q is nil even though there was no error"
,
path
)
}
}
}
func
TestCommands
(
t
*
testing
.
T
)
{
list
:=
[]
string
{
"/add"
,
...
...
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