mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-25 06:58:18 +08:00
commands: Fixed tests
This commit is contained in:

committed by
Juan Batiz-Benet

parent
32a2959348
commit
6302356e15
@ -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)")
|
||||
}
|
||||
|
Reference in New Issue
Block a user