You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package cmd
  4. import (
  5. "context"
  6. "testing"
  7. "code.gitea.io/gitea/modules/doctor"
  8. "code.gitea.io/gitea/modules/log"
  9. "github.com/stretchr/testify/assert"
  10. "github.com/urfave/cli/v2"
  11. )
  12. func TestDoctorRun(t *testing.T) {
  13. doctor.Register(&doctor.Check{
  14. Title: "Test Check",
  15. Name: "test-check",
  16. Run: func(ctx context.Context, logger log.Logger, autofix bool) error { return nil },
  17. SkipDatabaseInitialization: true,
  18. })
  19. app := cli.NewApp()
  20. app.Commands = []*cli.Command{cmdDoctorCheck}
  21. err := app.Run([]string{"./gitea", "check", "--run", "test-check"})
  22. assert.NoError(t, err)
  23. err = app.Run([]string{"./gitea", "check", "--run", "no-such"})
  24. assert.ErrorContains(t, err, `unknown checks: "no-such"`)
  25. err = app.Run([]string{"./gitea", "check", "--run", "test-check,no-such"})
  26. assert.ErrorContains(t, err, `unknown checks: "no-such"`)
  27. }