Minimize struct copying
by using pointer func receivers and slices of struct pointers where possible.
This commit is contained in:
@@ -42,13 +42,13 @@ func TestCommandFlagParsing(t *testing.T) {
|
||||
err := command.Run(context)
|
||||
|
||||
expect(t, err, c.expectedErr)
|
||||
expect(t, []string(context.Args()), c.testArgs)
|
||||
expect(t, context.Args().Slice(), c.testArgs)
|
||||
}
|
||||
}
|
||||
|
||||
func TestCommand_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) {
|
||||
app := NewApp()
|
||||
app.Commands = []Command{
|
||||
app.Commands = []*Command{
|
||||
{
|
||||
Name: "bar",
|
||||
Before: func(c *Context) error {
|
||||
@@ -75,11 +75,11 @@ func TestCommand_Run_DoesNotOverwriteErrorFromBefore(t *testing.T) {
|
||||
|
||||
func TestCommand_OnUsageError_WithWrongFlagValue(t *testing.T) {
|
||||
app := NewApp()
|
||||
app.Commands = []Command{
|
||||
app.Commands = []*Command{
|
||||
{
|
||||
Name: "bar",
|
||||
Flags: []Flag{
|
||||
IntFlag{Name: "flag"},
|
||||
&IntFlag{Name: "flag"},
|
||||
},
|
||||
OnUsageError: func(c *Context, err error, _ bool) error {
|
||||
if !strings.HasPrefix(err.Error(), "invalid value \"wrong\"") {
|
||||
|
Reference in New Issue
Block a user