@cryptotaxi247 / kubo / commits / 6302356e1

commands: Fixed tests

Matt Bell committed Oct 28, 2014 at 20:30 UTC 6302356e153f2da7d7c01bec35a0fd194462d67b
2 files changed +7 -3
commands/cli/parse_test.go
+6 -2
@@ -8,12 +8,13 @@ import (
8 )
9
10 func TestOptionParsing(t *testing.T) {
11 + subCmd := &commands.Command{}
12 cmd := &commands.Command{
13 Options: []commands.Option{
14 commands.Option{Names: []string{"b"}, Type: commands.String},
15 },
16 Subcommands: map[string]*commands.Command{
16 - "test": &commands.Command{},
17 + "test": subCmd,
18 },
19 }
20
@@ -37,11 +38,14 @@ func TestOptionParsing(t *testing.T) {
38 t.Error("Should have failed (duplicate option name)")
39 }
40
40 - path, args := parsePath([]string{"test", "beep", "boop"}, cmd)
41 + path, args, sub := parsePath([]string{"test", "beep", "boop"}, cmd)
42 if len(path) != 1 || path[0] != "test" {
43 t.Errorf("Returned path was defferent than expected: %v", path)
44 }
45 if len(args) != 2 || args[0] != "beep" || args[1] != "boop" {
46 t.Errorf("Returned args were different than expected: %v", args)
47 }
48 + if sub != subCmd {
49 + t.Errorf("Returned command was different than expected")
50 + }
51 }
commands/command_test.go
+1 -1
@@ -105,7 +105,7 @@ func TestRegistration(t *testing.T) {
105 Run: noop,
106 }
107
108 - res := cmdB.Call(NewRequest([]string{"a"}, nil, nil, nil))
108 + res := cmdB.Call(NewRequest([]string{"a"}, nil, nil, nil, nil))
109 if res.Error() == nil {
110 t.Error("Should have failed (option name collision)")
111 }