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:
@@ -513,11 +513,8 @@ func TestIsUserVisibleToViewer(t *testing.T) {
|
||||
}
|
||||
|
||||
func Test_ValidateUser(t *testing.T) {
|
||||
oldSetting := setting.Service.AllowedUserVisibilityModesSlice
|
||||
defer func() {
|
||||
setting.Service.AllowedUserVisibilityModesSlice = oldSetting
|
||||
}()
|
||||
setting.Service.AllowedUserVisibilityModesSlice = []bool{true, false, true}
|
||||
defer test.MockVariableValue(&setting.Service.AllowedUserVisibilityModesSlice, []bool{true, false, true})()
|
||||
|
||||
kases := map[*user_model.User]bool{
|
||||
{ID: 1, Visibility: structs.VisibleTypePublic}: true,
|
||||
{ID: 2, Visibility: structs.VisibleTypeLimited}: false,
|
||||
@@ -586,12 +583,7 @@ func TestDisabledUserFeatures(t *testing.T) {
|
||||
testValues := container.SetOf(setting.UserFeatureDeletion,
|
||||
setting.UserFeatureManageSSHKeys,
|
||||
setting.UserFeatureManageGPGKeys)
|
||||
|
||||
oldSetting := setting.Admin.ExternalUserDisableFeatures
|
||||
defer func() {
|
||||
setting.Admin.ExternalUserDisableFeatures = oldSetting
|
||||
}()
|
||||
setting.Admin.ExternalUserDisableFeatures = testValues
|
||||
defer test.MockVariableValue(&setting.Admin.ExternalUserDisableFeatures, testValues)()
|
||||
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||
|
||||
|
Reference in New Issue
Block a user