forked from forgejo/forgejo
Follow improve code quality (#21465)
After some discussion, introduce a new slice `brokenArgs` to make `gitCmd.Run()` return errors if any dynamic argument is invalid. Co-authored-by: delvh <dev.lh@web.de>
This commit is contained in:
parent
d98c5db58f
commit
677af6ac57
2 changed files with 23 additions and 11 deletions
|
@ -27,15 +27,13 @@ func TestRunWithContextStd(t *testing.T) {
|
|||
assert.Empty(t, stdout)
|
||||
}
|
||||
|
||||
assert.Panics(t, func() {
|
||||
cmd = NewCommand(context.Background())
|
||||
cmd.AddDynamicArguments("-test")
|
||||
})
|
||||
cmd = NewCommand(context.Background())
|
||||
cmd.AddDynamicArguments("-test")
|
||||
assert.ErrorIs(t, cmd.Run(&RunOpts{}), ErrBrokenCommand)
|
||||
|
||||
assert.Panics(t, func() {
|
||||
cmd = NewCommand(context.Background())
|
||||
cmd.AddDynamicArguments("--test")
|
||||
})
|
||||
cmd = NewCommand(context.Background())
|
||||
cmd.AddDynamicArguments("--test")
|
||||
assert.ErrorIs(t, cmd.Run(&RunOpts{}), ErrBrokenCommand)
|
||||
|
||||
subCmd := "version"
|
||||
cmd = NewCommand(context.Background()).AddDynamicArguments(subCmd) // for test purpose only, the sub-command should never be dynamic for production
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue