1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-07 19:17:21 +00:00

Migrate to urfave v3 (#34510)

migrate cli to urfave v3

add more cli tests

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
TheFox0x7
2025-06-10 14:35:12 +02:00
committed by GitHub
parent 2c341b6803
commit e9f5105e95
51 changed files with 1718 additions and 783 deletions

View File

@ -13,7 +13,7 @@ import (
"code.gitea.io/gitea/modules/util"
"github.com/stretchr/testify/assert"
"github.com/urfave/cli/v2"
"github.com/urfave/cli/v3"
)
func Test_CmdKeys(t *testing.T) {
@ -36,18 +36,21 @@ func Test_CmdKeys(t *testing.T) {
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
out := new(bytes.Buffer)
app := cli.NewApp()
app.Writer = out
app.Commands = []*cli.Command{cmd.CmdKeys}
var stdout, stderr bytes.Buffer
app := &cli.Command{
Writer: &stdout,
ErrWriter: &stderr,
Commands: []*cli.Command{cmd.CmdKeys},
}
cmd.CmdKeys.HideHelp = true
err := app.Run(append([]string{"prog"}, tt.args...))
err := app.Run(t.Context(), append([]string{"prog"}, tt.args...))
if tt.wantErr {
assert.Error(t, err)
assert.Equal(t, tt.expectedOutput, stderr.String())
} else {
assert.NoError(t, err)
assert.Equal(t, tt.expectedOutput, stdout.String())
}
assert.Equal(t, tt.expectedOutput, out.String())
})
}
})