wip regression test

main
[[ BOT ]] Lynn Cyrin 5 years ago
parent 23c8303026
commit 4381738fb5
No known key found for this signature in database
GPG Key ID: 4E7214CB460A2400

@ -1187,6 +1187,43 @@ func TestRequiredFlagAppRunBehavior(t *testing.T) {
} }
} }
func TestAppRunPassThroughRegression(t *testing.T) {
tdata := []struct {
testCase string
appFlags []Flag
appRunInput []string
appCommands []Command
expectedAnError bool
}{
{ // docker run --rm ubuntu bash
appRunInput: []string{"myCLI", "myCommand", "--someFlag", "someInput", "docker", "run", "--rm", "ubuntu", "bash"},
appCommands: []Command{{
Name: "myCommand",
Flags: []Flag{StringFlag{Name: "someFlag"}},
}},
},
}
for _, test := range tdata {
t.Run(test.testCase, func(t *testing.T) {
// setup
app := NewApp()
app.Flags = test.appFlags
app.Commands = test.appCommands
// logic under test
err := app.Run(test.appRunInput)
// assertions
if test.expectedAnError && err == nil {
t.Errorf("expected an error, but there was none")
}
if !test.expectedAnError && err != nil {
t.Errorf("did not expected an error, but there was one: %s", err)
}
})
}
}
func TestAppHelpPrinter(t *testing.T) { func TestAppHelpPrinter(t *testing.T) {
oldPrinter := HelpPrinter oldPrinter := HelpPrinter
defer func() { defer func() {

Loading…
Cancel
Save