mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Refactor some tests (#34580)
1. use `test.MockVariableValue` as much as possible 2. avoid `time.Sleep` as much as possible
This commit is contained in:
@@ -22,8 +22,7 @@ import (
|
||||
|
||||
func TestSignup(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
setting.Service.EnableCaptcha = false
|
||||
defer test.MockVariableValue(&setting.Service.EnableCaptcha, false)()
|
||||
|
||||
req := NewRequestWithValues(t, "POST", "/user/sign_up", map[string]string{
|
||||
"user_name": "exampleUser",
|
||||
@@ -40,9 +39,8 @@ func TestSignup(t *testing.T) {
|
||||
|
||||
func TestSignupAsRestricted(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
setting.Service.EnableCaptcha = false
|
||||
setting.Service.DefaultUserIsRestricted = true
|
||||
defer test.MockVariableValue(&setting.Service.EnableCaptcha, false)()
|
||||
defer test.MockVariableValue(&setting.Service.DefaultUserIsRestricted, true)()
|
||||
|
||||
req := NewRequestWithValues(t, "POST", "/user/sign_up", map[string]string{
|
||||
"user_name": "restrictedUser",
|
||||
@@ -62,8 +60,7 @@ func TestSignupAsRestricted(t *testing.T) {
|
||||
|
||||
func TestSignupEmailValidation(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
setting.Service.EnableCaptcha = false
|
||||
defer test.MockVariableValue(&setting.Service.EnableCaptcha, false)()
|
||||
|
||||
tests := []struct {
|
||||
email string
|
||||
|
Reference in New Issue
Block a user