alternative to PR "improve code quality" (#21464)
This PR doesn't require new git version, and can be backported easily. Co-authored-by: 6543 <6543@obermui.de>
This commit is contained in:
parent
7917123209
commit
d98c5db58f
6 changed files with 52 additions and 25 deletions
|
@ -26,4 +26,21 @@ func TestRunWithContextStd(t *testing.T) {
|
|||
assert.Contains(t, err.Error(), "exit status 129 - unknown option:")
|
||||
assert.Empty(t, stdout)
|
||||
}
|
||||
|
||||
assert.Panics(t, func() {
|
||||
cmd = NewCommand(context.Background())
|
||||
cmd.AddDynamicArguments("-test")
|
||||
})
|
||||
|
||||
assert.Panics(t, func() {
|
||||
cmd = NewCommand(context.Background())
|
||||
cmd.AddDynamicArguments("--test")
|
||||
})
|
||||
|
||||
subCmd := "version"
|
||||
cmd = NewCommand(context.Background()).AddDynamicArguments(subCmd) // for test purpose only, the sub-command should never be dynamic for production
|
||||
stdout, stderr, err = cmd.RunStdString(&RunOpts{})
|
||||
assert.NoError(t, err)
|
||||
assert.Empty(t, stderr)
|
||||
assert.Contains(t, stdout, "git version")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue