Skip to content

Commit

Permalink
restore 100% code coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
alexflint committed Mar 31, 2024
1 parent 5ec29ce commit 68948b2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
7 changes: 0 additions & 7 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions parse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 68948b2

Please sign in to comment.