From 96d543cf2ccfa99a2d4589fa21a6b6ce939dd4de Mon Sep 17 00:00:00 2001 From: tummychow Date: Wed, 26 Mar 2014 04:54:47 -0400 Subject: [PATCH] Reset root command lists in testing This fixes some issues that appear when testing prefix invocations. Since the root command lists weren't being cleared, the list would persist between tests, so there would be multiple instances of each command. Then, if you tried to match a prefix of one of those commands, you'd get two matches (one for each instance) and the command would fail. Resetting the root command lists prevents them from persisting between tests, resolving this issue. --- cobra_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cobra_test.go b/cobra_test.go index 96fffb4..b412ee2 100644 --- a/cobra_test.go +++ b/cobra_test.go @@ -81,6 +81,8 @@ func commandInit() { cmdEcho.ResetCommands() cmdPrint.ResetCommands() cmdTimes.ResetCommands() + cmdRootNoRun.ResetCommands() + cmdRootWithRun.ResetCommands() } func initialize() *Command {