Commit 6302356e authored by Matt Bell's avatar Matt Bell Committed by Juan Batiz-Benet

commands: Fixed tests

parent 32a29593
......@@ -8,12 +8,13 @@ import (
)
func TestOptionParsing(t *testing.T) {
subCmd := &commands.Command{}
cmd := &commands.Command{
Options: []commands.Option{
commands.Option{Names: []string{"b"}, Type: commands.String},
},
Subcommands: map[string]*commands.Command{
"test": &commands.Command{},
"test": subCmd,
},
}
......@@ -37,11 +38,14 @@ func TestOptionParsing(t *testing.T) {
t.Error("Should have failed (duplicate option name)")
}
path, args := parsePath([]string{"test", "beep", "boop"}, cmd)
path, args, sub := parsePath([]string{"test", "beep", "boop"}, cmd)
if len(path) != 1 || path[0] != "test" {
t.Errorf("Returned path was defferent than expected: %v", path)
}
if len(args) != 2 || args[0] != "beep" || args[1] != "boop" {
t.Errorf("Returned args were different than expected: %v", args)
}
if sub != subCmd {
t.Errorf("Returned command was different than expected")
}
}
......@@ -105,7 +105,7 @@ func TestRegistration(t *testing.T) {
Run: noop,
}
res := cmdB.Call(NewRequest([]string{"a"}, nil, nil, nil))
res := cmdB.Call(NewRequest([]string{"a"}, nil, nil, nil, nil))
if res.Error() == nil {
t.Error("Should have failed (option name collision)")
}
......
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