.devcontainer
.gitea
.github
assets
build
cmd
actions.go
admin.go
admin_auth.go
admin_auth_ldap.go
admin_auth_ldap_test.go
admin_auth_oauth.go
admin_auth_oauth_test.go
admin_auth_smtp.go
admin_auth_smtp_test.go
admin_regenerate.go
admin_user.go
admin_user_change_password.go
admin_user_change_password_test.go
admin_user_create.go
admin_user_create_test.go
admin_user_delete.go
admin_user_delete_test.go
admin_user_generate_access_token.go
admin_user_list.go
admin_user_must_change_password.go
admin_user_must_change_password_test.go
cert.go
cert_test.go
cmd.go
docs.go
doctor.go
doctor_convert.go
doctor_test.go
dump.go
dump_repo.go
embedded.go
generate.go
hook.go
hook_test.go
keys.go
mailer.go
main.go
main_test.go
manager.go
manager_logging.go
migrate.go
migrate_storage.go
migrate_storage_test.go
restore_repo.go
serv.go
web.go
web_acme.go
web_graceful.go
web_https.go
contrib
custom
docker
models
modules
options
public
routers
services
snap
templates
tests
tools
web_src
.air.toml
.changelog.yml
.dockerignore
.editorconfig
.envrc
.eslintrc.cjs
.gitattributes
.gitignore
.gitpod.yml
.golangci.yml
.ignore
.mailmap
.markdownlint.yaml
.npmrc
.spectral.yaml
.yamllint.yaml
BSDmakefile
CHANGELOG-archived.md
CHANGELOG.md
CODE_OF_CONDUCT.md
CONTRIBUTING.md
DCO
Dockerfile
Dockerfile.rootless
LICENSE
MAINTAINERS
Makefile
README.md
README.zh-cn.md
README.zh-tw.md
SECURITY.md
build.go
crowdin.yml
flake.lock
flake.nix
go.mod
go.sum
main.go
main_timezones.go
package-lock.json
package.json
playwright.config.ts
poetry.lock
poetry.toml
pyproject.toml
stylelint.config.js
tailwind.config.js
tsconfig.json
updates.config.js
vitest.config.ts
webpack.config.js

migrate cli to urfave v3 add more cli tests --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
35 lines
986 B
Go
35 lines
986 B
Go
// Copyright 2023 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"code.gitea.io/gitea/modules/log"
|
|
"code.gitea.io/gitea/services/doctor"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
"github.com/urfave/cli/v3"
|
|
)
|
|
|
|
func TestDoctorRun(t *testing.T) {
|
|
doctor.Register(&doctor.Check{
|
|
Title: "Test Check",
|
|
Name: "test-check",
|
|
Run: func(ctx context.Context, logger log.Logger, autofix bool) error { return nil },
|
|
|
|
SkipDatabaseInitialization: true,
|
|
})
|
|
app := &cli.Command{
|
|
Commands: []*cli.Command{cmdDoctorCheck},
|
|
}
|
|
err := app.Run(t.Context(), []string{"./gitea", "check", "--run", "test-check"})
|
|
assert.NoError(t, err)
|
|
err = app.Run(t.Context(), []string{"./gitea", "check", "--run", "no-such"})
|
|
assert.ErrorContains(t, err, `unknown checks: "no-such"`)
|
|
err = app.Run(t.Context(), []string{"./gitea", "check", "--run", "test-check,no-such"})
|
|
assert.ErrorContains(t, err, `unknown checks: "no-such"`)
|
|
}
|