mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 10:18:38 +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:
@@ -13,6 +13,7 @@ import (
|
||||
user_model "code.gitea.io/gitea/models/user"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/test"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
@@ -38,7 +39,7 @@ func TestForkRepository(t *testing.T) {
|
||||
assert.False(t, repo_model.IsErrReachLimitOfRepo(err))
|
||||
|
||||
// change AllowForkWithoutMaximumLimit to false for the test
|
||||
setting.Repository.AllowForkWithoutMaximumLimit = false
|
||||
defer test.MockVariableValue(&setting.Repository.AllowForkWithoutMaximumLimit, false)()
|
||||
// user has reached maximum limit of repositories
|
||||
user.MaxRepoCreation = 0
|
||||
fork2, err := ForkRepository(git.DefaultContext, user, user, ForkRepoOptions{
|
||||
|
Reference in New Issue
Block a user