diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2023-05-04 11:55:35 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-04 11:55:35 +0800 |
commit | 377a0a20f01a62f15a1504a3bba6cf6cc0c98bea (patch) | |
tree | e86a1818f23be1605a4cd707fadc7dcdce546d18 /routers/web/user/setting | |
parent | a2fe68e50ba819daed9b0e28166a749d18c58750 (diff) | |
download | gitea-377a0a20f01a62f15a1504a3bba6cf6cc0c98bea.tar.gz gitea-377a0a20f01a62f15a1504a3bba6cf6cc0c98bea.zip |
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.
Diffstat (limited to 'routers/web/user/setting')
-rw-r--r-- | routers/web/user/setting/account_test.go | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/routers/web/user/setting/account_test.go b/routers/web/user/setting/account_test.go index 5fce41f065..569d597722 100644 --- a/routers/web/user/setting/account_test.go +++ b/routers/web/user/setting/account_test.go @@ -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, - }) - AccountPost(ctx) + 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()) + assert.Contains(t, ctx.Flash.ErrorMsg, req.Message) + assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status()) + }) } } |