mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Merge setting.InitXXX into one function with options (#24389)
This PR will merge 3 Init functions on setting packages as 1 and introduce an options struct.
This commit is contained in:
@@ -13,10 +13,11 @@ import (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
setting.InitProviderAndLoadCommonSettingsForTest()
|
||||
setting.LoadQueueSettings()
|
||||
unittest.MainTest(m, &unittest.TestOptions{
|
||||
GiteaRootPath: filepath.Join("..", "..", "..", ".."),
|
||||
SetUp: webhook_service.Init,
|
||||
SetUp: func() error {
|
||||
setting.LoadQueueSettings()
|
||||
return webhook_service.Init()
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@@ -15,8 +15,9 @@ import (
|
||||
|
||||
// PreloadSettings preloads the configuration to check if we need to run install
|
||||
func PreloadSettings(ctx context.Context) bool {
|
||||
setting.InitProviderAllowEmpty()
|
||||
setting.LoadCommonSettings()
|
||||
setting.Init(&setting.Options{
|
||||
AllowEmpty: true,
|
||||
})
|
||||
if !setting.InstallLock {
|
||||
log.Info("AppPath: %s", setting.AppPath)
|
||||
log.Info("AppWorkPath: %s", setting.AppWorkPath)
|
||||
@@ -38,8 +39,7 @@ func PreloadSettings(ctx context.Context) bool {
|
||||
|
||||
// reloadSettings reloads the existing settings and starts up the database
|
||||
func reloadSettings(ctx context.Context) {
|
||||
setting.InitProviderFromExistingFile()
|
||||
setting.LoadCommonSettings()
|
||||
setting.Init(&setting.Options{})
|
||||
setting.LoadDBSetting()
|
||||
if setting.InstallLock {
|
||||
if err := common.InitDBEngine(ctx); err == nil {
|
||||
|
@@ -80,19 +80,22 @@ func TestChangePassword(t *testing.T) {
|
||||
PasswordComplexity: pcLU,
|
||||
},
|
||||
} {
|
||||
unittest.PrepareTestEnv(t)
|
||||
ctx := test.MockContext(t, "user/settings/security")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
t.Run(req.OldPassword+"__"+req.NewPassword, func(t *testing.T) {
|
||||
unittest.PrepareTestEnv(t)
|
||||
setting.PasswordComplexity = req.PasswordComplexity
|
||||
ctx := test.MockContext(t, "user/settings/security")
|
||||
test.LoadUser(t, ctx, 2)
|
||||
test.LoadRepo(t, ctx, 1)
|
||||
|
||||
web.SetForm(ctx, &forms.ChangePasswordForm{
|
||||
OldPassword: req.OldPassword,
|
||||
Password: req.NewPassword,
|
||||
Retype: req.Retype,
|
||||
web.SetForm(ctx, &forms.ChangePasswordForm{
|
||||
OldPassword: req.OldPassword,
|
||||
Password: req.NewPassword,
|
||||
Retype: req.Retype,
|
||||
})
|
||||
AccountPost(ctx)
|
||||
|
||||
assert.Contains(t, ctx.Flash.ErrorMsg, req.Message)
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
})
|
||||
AccountPost(ctx)
|
||||
|
||||
assert.Contains(t, ctx.Flash.ErrorMsg, req.Message)
|
||||
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user