mirror of
https://github.com/spf13/cobra
synced 2024-11-24 22:57:12 +00:00
add TestHelpCommandExecutedWithPersistentRequiredFlags
This commit is contained in:
parent
43e4ad49f7
commit
314c9b86c2
1 changed files with 12 additions and 0 deletions
|
@ -885,6 +885,18 @@ func TestHelpCommandExecuted(t *testing.T) {
|
|||
checkStringContains(t, output, rootCmd.Long)
|
||||
}
|
||||
|
||||
func TestHelpCommandExecutedWithPersistentRequiredFlags(t *testing.T) {
|
||||
rootCmd := &Command{Use: "root", Run: emptyRun}
|
||||
rootCmd.PersistentFlags().Bool("foo", false, "")
|
||||
childCmd := &Command{Use: "child", Run: emptyRun}
|
||||
rootCmd.AddCommand(childCmd)
|
||||
assertNoErr(t, rootCmd.MarkPersistentFlagRequired("foo"))
|
||||
|
||||
if _, err := executeCommand(rootCmd, "help"); err != nil {
|
||||
t.Errorf("unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHelpCommandExecutedOnChild(t *testing.T) {
|
||||
rootCmd := &Command{Use: "root", Run: emptyRun}
|
||||
childCmd := &Command{Use: "child", Long: "Long description", Run: emptyRun}
|
||||
|
|
Loading…
Reference in a new issue