update tests
This commit is contained in:
parent
192ce003d9
commit
2172d382b6
@ -6,24 +6,43 @@ import (
|
|||||||
|
|
||||||
// TestRegression tests a regression that was merged between versions 1.20.0 and 1.21.0
|
// TestRegression tests a regression that was merged between versions 1.20.0 and 1.21.0
|
||||||
// The included app.Run line worked in 1.20.0, and then was broken in 1.21.0.
|
// The included app.Run line worked in 1.20.0, and then was broken in 1.21.0.
|
||||||
|
// Relevant PR: https://github.com/urfave/cli/pull/872
|
||||||
func TestVersionOneTwoOneRegression(t *testing.T) {
|
func TestVersionOneTwoOneRegression(t *testing.T) {
|
||||||
// setup
|
testData := []struct {
|
||||||
app := NewApp()
|
testCase string
|
||||||
app.Commands = []Command{{
|
appRunInput []string
|
||||||
Name: "command",
|
}{
|
||||||
Flags: []Flag{
|
// assertion: empty input, when a required flag is present, errors
|
||||||
StringFlag{
|
{
|
||||||
Name: "flagone",
|
testCase: "with_dash_dash",
|
||||||
},
|
appRunInput: []string{"cli", "command", "--flagone", "flagvalue", "--", "docker", "image", "ls", "--no-trunc"},
|
||||||
},
|
},
|
||||||
Action: func(c *Context) error { return nil },
|
{
|
||||||
}}
|
testCase: "without_dash_dash",
|
||||||
|
appRunInput: []string{"cli", "command", "--flagone", "flagvalue", "docker", "image", "ls", "--no-trunc"},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, test := range testData {
|
||||||
|
t.Run(test.testCase, func(t *testing.T) {
|
||||||
|
// setup
|
||||||
|
app := NewApp()
|
||||||
|
app.Commands = []Command{{
|
||||||
|
Name: "command",
|
||||||
|
Flags: []Flag{
|
||||||
|
StringFlag{
|
||||||
|
Name: "flagone",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Action: func(c *Context) error { return nil },
|
||||||
|
}}
|
||||||
|
|
||||||
// logic under test
|
// logic under test
|
||||||
err := app.Run([]string{"cli", "command", "--flagone", "flagvalue", "docker", "image", "ls", "--no-trunc"})
|
err := app.Run(test.appRunInput)
|
||||||
|
|
||||||
// assertions
|
// assertions
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("did not expected an error, but there was one: %s", err)
|
t.Errorf("did not expected an error, but there was one: %s", err)
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user