add test to check required flags will be ignored for bash, zsh, fish, powershell completion

This commit is contained in:
Jun Nishimura 2023-07-09 16:12:28 +09:00
parent 314c9b86c2
commit 10b0388a6e

View file

@ -2447,6 +2447,17 @@ func TestDefaultCompletionCmd(t *testing.T) {
rootCmd.CompletionOptions.HiddenDefaultCmd = false rootCmd.CompletionOptions.HiddenDefaultCmd = false
// Remove completion command for the next test // Remove completion command for the next test
removeCompCmd(rootCmd) removeCompCmd(rootCmd)
// Test that required flag will be ignored
rootCmd.PersistentFlags().Bool("foo", false, "")
assertNoErr(t, rootCmd.MarkPersistentFlagRequired("foo"))
for _, shell := range []string{"bash", "fish", "powershell", "zsh"} {
if _, err = executeCommand(rootCmd, compCmdName, shell); err != nil {
t.Errorf("Unexpected error: %v", err)
}
}
// Remove completion command for the next test
removeCompCmd(rootCmd)
} }
func TestCompleteCompletion(t *testing.T) { func TestCompleteCompletion(t *testing.T) {