Skip to content

Commit

Permalink
commands/cli: Added path/args test
Browse files Browse the repository at this point in the history
  • Loading branch information
mappum committed Oct 14, 2014
1 parent 8536ec0 commit 72ece2d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions commands/cli/parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package cli
import (
//"fmt"
"testing"

"github.com/jbenet/go-ipfs/commands"
)

func TestOptionParsing(t *testing.T) {
Expand All @@ -20,4 +22,17 @@ func TestOptionParsing(t *testing.T) {
if len(input) != 2 || input[0] != "test" || input[1] != "test2" {
t.Error("Returned input was different than expected: %v", input)
}

cmd := &commands.Command{}
cmd.Register("test", &commands.Command{})
path, args, err := path([]string{ "test", "beep", "boop" }, cmd)
if err != nil {
t.Error("Should have passed")
}
if len(path) != 1 || path[0] != "test" {
t.Error("Returned path was defferent than expected: %v", path)
}
if len(args) != 2 || args[0] != "beep" || args[1] != "boop" {
t.Error("Returned args were different than expected: %v", args)
}
}

0 comments on commit 72ece2d

Please sign in to comment.