mirror of
https://github.com/spf13/cobra
synced 2024-12-28 23:37:09 +00:00
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.
This commit is contained in:
parent
f4c075f8f8
commit
96d543cf2c
1 changed files with 2 additions and 0 deletions
|
@ -81,6 +81,8 @@ func commandInit() {
|
|||
cmdEcho.ResetCommands()
|
||||
cmdPrint.ResetCommands()
|
||||
cmdTimes.ResetCommands()
|
||||
cmdRootNoRun.ResetCommands()
|
||||
cmdRootWithRun.ResetCommands()
|
||||
}
|
||||
|
||||
func initialize() *Command {
|
||||
|
|
Loading…
Reference in a new issue