Make test case compatible with Go 1.17 (#1299)

* Make test case compatible with Go 1.17

* tweak test case to bring coverage back up
This commit is contained in:
William Wilson 2021-12-05 13:56:34 -06:00 committed by GitHub
parent 12b7dfd08c
commit e8d8173889
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -476,18 +476,18 @@ func TestApp_RunAsSubCommandIncorrectUsage(t *testing.T) {
a := App{ a := App{
Name: "cmd", Name: "cmd",
Flags: []Flag{ Flags: []Flag{
&StringFlag{Name: "--foo"}, &StringFlag{Name: "foo"},
}, },
Writer: bytes.NewBufferString(""), Writer: bytes.NewBufferString(""),
} }
set := flag.NewFlagSet("", flag.ContinueOnError) set := flag.NewFlagSet("", flag.ContinueOnError)
_ = set.Parse([]string{"", "---foo"}) _ = set.Parse([]string{"", "-bar"})
c := &Context{flagSet: set} c := &Context{flagSet: set}
err := a.RunAsSubcommand(c) err := a.RunAsSubcommand(c)
expect(t, err, errors.New("bad flag syntax: ---foo")) expect(t, err.Error(), "flag provided but not defined: -bar")
} }
func TestApp_CommandWithFlagBeforeTerminator(t *testing.T) { func TestApp_CommandWithFlagBeforeTerminator(t *testing.T) {