Skip to content

Commit

Permalink
Merge pull request #1498 from dearchap/optimize_command_run
Browse files Browse the repository at this point in the history
  • Loading branch information
dearchap committed Oct 14, 2022
2 parents 89e331f + 33d08c3 commit 0d0d329
Show file tree
Hide file tree
Showing 13 changed files with 292 additions and 422 deletions.
18 changes: 9 additions & 9 deletions altsrc/json_command_test.go
Expand Up @@ -46,7 +46,7 @@ func TestCommandJSONFileTest(t *testing.T) {
},
}
command.Before = InitInputSourceWithContext(command.Flags, NewJSONSourceFromFlagFunc("load"))
err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -81,7 +81,7 @@ func TestCommandJSONFileTestGlobalEnvVarWins(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewJSONSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestCommandJSONFileTestGlobalEnvVarWinsNested(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewJSONSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestCommandJSONFileTestSpecifiedFlagWins(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewJSONSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -180,7 +180,7 @@ func TestCommandJSONFileTestSpecifiedFlagWinsNested(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewJSONSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -212,7 +212,7 @@ func TestCommandJSONFileTestDefaultValueFileWins(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewJSONSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -244,7 +244,7 @@ func TestCommandJSONFileTestDefaultValueFileWinsNested(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewJSONSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -278,7 +278,7 @@ func TestCommandJSONFileFlagHasDefaultGlobalEnvJSONSetGlobalEnvWins(t *testing.T
&cli.StringFlag{Name: "load"}},
}
command.Before = InitInputSourceWithContext(command.Flags, NewJSONSourceFromFlagFunc("load"))
err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -312,7 +312,7 @@ func TestCommandJSONFileFlagHasDefaultGlobalEnvJSONSetGlobalEnvWinsNested(t *tes
&cli.StringFlag{Name: "load"}},
}
command.Before = InitInputSourceWithContext(command.Flags, NewJSONSourceFromFlagFunc("load"))
err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down
18 changes: 9 additions & 9 deletions altsrc/toml_command_test.go
Expand Up @@ -34,7 +34,7 @@ func TestCommandTomFileTest(t *testing.T) {
&cli.StringFlag{Name: "load"}},
}
command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load"))
err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -68,7 +68,7 @@ func TestCommandTomlFileTestGlobalEnvVarWins(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -102,7 +102,7 @@ func TestCommandTomlFileTestGlobalEnvVarWinsNested(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -134,7 +134,7 @@ func TestCommandTomlFileTestSpecifiedFlagWins(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -167,7 +167,7 @@ func TestCommandTomlFileTestSpecifiedFlagWinsNested(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -199,7 +199,7 @@ func TestCommandTomlFileTestDefaultValueFileWins(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -231,7 +231,7 @@ func TestCommandTomlFileTestDefaultValueFileWinsNested(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -265,7 +265,7 @@ func TestCommandTomlFileFlagHasDefaultGlobalEnvTomlSetGlobalEnvWins(t *testing.T
&cli.StringFlag{Name: "load"}},
}
command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load"))
err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -299,7 +299,7 @@ func TestCommandTomlFileFlagHasDefaultGlobalEnvTomlSetGlobalEnvWinsNested(t *tes
&cli.StringFlag{Name: "load"}},
}
command.Before = InitInputSourceWithContext(command.Flags, NewTomlSourceFromFlagFunc("load"))
err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
18 changes: 9 additions & 9 deletions altsrc/yaml_command_test.go
Expand Up @@ -34,7 +34,7 @@ func TestCommandYamlFileTest(t *testing.T) {
&cli.StringFlag{Name: "load"}},
}
command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))
err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -68,7 +68,7 @@ func TestCommandYamlFileTestGlobalEnvVarWins(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -103,7 +103,7 @@ func TestCommandYamlFileTestGlobalEnvVarWinsNested(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -135,7 +135,7 @@ func TestCommandYamlFileTestSpecifiedFlagWins(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -168,7 +168,7 @@ func TestCommandYamlFileTestSpecifiedFlagWinsNested(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -200,7 +200,7 @@ func TestCommandYamlFileTestDefaultValueFileWins(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -233,7 +233,7 @@ func TestCommandYamlFileTestDefaultValueFileWinsNested(t *testing.T) {
}
command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))

err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -267,7 +267,7 @@ func TestCommandYamlFileFlagHasDefaultGlobalEnvYamlSetGlobalEnvWins(t *testing.T
&cli.StringFlag{Name: "load"}},
}
command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))
err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}
Expand Down Expand Up @@ -302,7 +302,7 @@ func TestCommandYamlFileFlagHasDefaultGlobalEnvYamlSetGlobalEnvWinsNested(t *tes
&cli.StringFlag{Name: "load"}},
}
command.Before = InitInputSourceWithContext(command.Flags, NewYamlSourceFromFlagFunc("load"))
err := command.Run(c)
err := command.Run(c, test...)

expect(t, err, nil)
}

0 comments on commit 0d0d329

Please sign in to comment.