fill out test cases

main
Lynn Cyrin 5 years ago
parent 746866c10d
commit 80d7e91191
No known key found for this signature in database
GPG Key ID: EE9CCB427DFEC897

@ -879,15 +879,26 @@ func TestAppNoHelpFlag(t *testing.T) {
func TestAppHelpPrinter(t *testing.T) { func TestAppHelpPrinter(t *testing.T) {
tdata := []struct { tdata := []struct {
testCase string testCase string
flags []Flag flags []Flag
appRunInput []string
}{ }{
{ {
testCase: "prints_help_and_does_not_error", testCase: "prints_help_case_one",
appRunInput: []string{""},
}, },
{ {
testCase: "prints_help_and_does_not_error_when_required_flag_is_present", testCase: "prints_help_case_two",
flags: []Flag{StringFlag{Name: "flag", Required: true}}, appRunInput: []string{"-h"},
},
{
testCase: "prints_help_case_three",
appRunInput: []string{"testCommand", "-h"},
},
{
testCase: "prints_help_when_required_flag_is_present",
flags: []Flag{StringFlag{Name: "flag", Required: true}},
appRunInput: []string{"testCommand", "-h"},
}, },
} }
for _, test := range tdata { for _, test := range tdata {
@ -904,7 +915,7 @@ func TestAppHelpPrinter(t *testing.T) {
app := NewApp() app := NewApp()
app.Flags = test.flags app.Flags = test.flags
err := app.Run([]string{"testCommand", "-h"}) err := app.Run(test.appRunInput)
if wasCalled == false { if wasCalled == false {
t.Errorf("Help printer expected to be called, but was not") t.Errorf("Help printer expected to be called, but was not")

Loading…
Cancel
Save