提交 6302356e 作者: Matt Bell 提交者: Juan Batiz-Benet

commands: Fixed tests

上级 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 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论