// TestExecute checks that root.Execute would exit if an error is returned.
TestExecute checks that root.Execute would exit if an error is returned.
// TestExecute checks that root . Execute would exit if an error is returned .
func TestExecute(t *testing.T) {
	exited := false
	osExit = func(int) {
		exited = true
	}
	defer func() {
		osExit = os.Exit
	}()
	outErr := new(bytes.Buffer)
	RootCmd.SetErr(outErr)
	RootCmd.SetArgs([]string{"--option-that-will-never-be-used"})
	Execute()
	if !exited {
		t.Errorf(`Would not have exited on RootCmd execution error`)
	}
}
func TestExecute ( t * testing . T ) { exited := false osExit = func ( int ) { exited = true } defer func ( ) { osExit = os . Exit } ( ) outErr := new ( bytes . Buffer ) RootCmd . SetErr ( outErr ) RootCmd . SetArgs ( [ ] string { " " } ) Execute ( ) if ! exited { t . Errorf ( `Would not have exited on RootCmd execution error` ) } }
TestExecute checks that root.Execute would exit if an error is returned.
TestExecute checks that root . Execute would exit if an error is returned .
// execute := RootCmd.Execute // RootCmd.Execute = func(*cobra.Command) error { // 	return errors.New("mock") // } // RootCmd.Execute = execute