diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2022-10-15 18:49:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-15 12:49:26 +0200 |
commit | d98c5db58fdeded983bf5c0fe781fd7b77a1235f (patch) | |
tree | 2816c975613f2f44b80bdd9cba01ebb1ee6bc9e4 /modules/git/command_test.go | |
parent | 7917123209d7974662baccf21346f1989247550a (diff) | |
download | gitea-d98c5db58fdeded983bf5c0fe781fd7b77a1235f.tar.gz gitea-d98c5db58fdeded983bf5c0fe781fd7b77a1235f.zip |
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>
Diffstat (limited to 'modules/git/command_test.go')
-rw-r--r-- | modules/git/command_test.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/modules/git/command_test.go b/modules/git/command_test.go index 67d4ca388e..c965ea230d 100644 --- a/modules/git/command_test.go +++ b/modules/git/command_test.go @@ -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") } |