restore 100% code coverage

This commit is contained in:
Alex Flint 2024-03-31 12:05:26 -04:00
parent 5ec29ce755
commit 68948b2ac1
2 changed files with 8 additions and 7 deletions

View File

@ -85,13 +85,6 @@ func MustParse(dest ...interface{}) *Parser {
// mustParse is a helper that facilitates testing
func mustParse(config Config, dest ...interface{}) *Parser {
if config.Exit == nil {
config.Exit = os.Exit
}
if config.Out == nil {
config.Out = os.Stdout
}
p, err := NewParser(config, dest...)
if err != nil {
fmt.Fprintln(config.Out, err)

View File

@ -1735,3 +1735,11 @@ func TestSubcommandGlobalFlag_InCommand_Strict_Inner(t *testing.T) {
assert.False(t, args.Global)
assert.True(t, args.Sub.Guard)
}
func TestExitFunctionAndOutStreamGetFilledIn(t *testing.T) {
var args struct{}
p, err := NewParser(Config{}, &args)
require.NoError(t, err)
assert.NotNil(t, p.config.Exit) // go prohibits function pointer comparison
assert.Equal(t, p.config.Out, os.Stdout)
}