mirror of
https://github.com/spf13/cobra
synced 2024-11-04 21:07:19 +00:00
Add basic test for prefix matching
This commit is contained in:
parent
96d543cf2c
commit
4c29b190e0
1 changed files with 18 additions and 0 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue