From 72ece2dfb39536a6604489788f6c2ce15d642ea1 Mon Sep 17 00:00:00 2001 From: Matt Bell Date: Tue, 14 Oct 2014 12:48:38 -0700 Subject: [PATCH] commands/cli: Added path/args test --- commands/cli/parse_test.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/commands/cli/parse_test.go b/commands/cli/parse_test.go index 6082f95941f5..b1a051ad4c82 100644 --- a/commands/cli/parse_test.go +++ b/commands/cli/parse_test.go @@ -3,6 +3,8 @@ package cli import ( //"fmt" "testing" + + "github.com/jbenet/go-ipfs/commands" ) func TestOptionParsing(t *testing.T) { @@ -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) + } }