Commit 8061117e authored by keks's avatar keks Committed by Jeromy

core/commands: add TestROCommands

License: MIT
Signed-off-by: default avatarkeks <keks@cryptoscope.co>
parent aec44bc4
......@@ -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",
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment