From 4c29b190e047b4c0639dd14820ab0a7487de7d7f Mon Sep 17 00:00:00 2001 From: tummychow Date: Wed, 26 Mar 2014 04:56:46 -0400 Subject: [PATCH] Add basic test for prefix matching --- cobra_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cobra_test.go b/cobra_test.go index b412ee2..b23ac2f 100644 --- a/cobra_test.go +++ b/cobra_test.go @@ -138,6 +138,24 @@ func TestChildCommand(t *testing.T) { } } +func TestChildCommandPrefix(t *testing.T) { + c := initialize() + cmdEcho.AddCommand(cmdTimes) + c.AddCommand(cmdPrint, cmdEcho) + c.SetArgs(strings.Split("ech tim one two", " ")) + c.Execute() + + if te != nil || tp != nil { + t.Error("Wrong command called") + } + if tt == nil { + t.Error("Wrong command called") + } + if strings.Join(tt, " ") != "one two" { + t.Error("Command didn't parse correctly") + } +} + func TestFlagLong(t *testing.T) { c := initialize() c.AddCommand(cmdPrint, cmdEcho, cmdTimes)