@cryptotaxi247 / kubo / commits / f437230d8

commands/cli: Added path/args test

Matt Bell committed Oct 14, 2014 at 12:48 UTC f437230d8871de33c676f359eddd45d1367416b5
1 file changed +15
commands/cli/parse_test.go
+15
@@ -3,6 +3,8 @@ package cli
3 import (
4 //"fmt"
5 "testing"
6 +
7 + "github.com/jbenet/go-ipfs/commands"
8 )
9
10 func TestOptionParsing(t *testing.T) {
@@ -20,4 +22,17 @@ func TestOptionParsing(t *testing.T) {
22 if len(input) != 2 || input[0] != "test" || input[1] != "test2" {
23 t.Error("Returned input was different than expected: %v", input)
24 }
25 +
26 + cmd := &commands.Command{}
27 + cmd.Register("test", &commands.Command{})
28 + path, args, err := path([]string{ "test", "beep", "boop" }, cmd)
29 + if err != nil {
30 + t.Error("Should have passed")
31 + }
32 + if len(path) != 1 || path[0] != "test" {
33 + t.Error("Returned path was defferent than expected: %v", path)
34 + }
35 + if len(args) != 2 || args[0] != "beep" || args[1] != "boop" {
36 + t.Error("Returned args were different than expected: %v", args)
37 + }
38 }