1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-10 04:27:22 +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:
wxiaoguang
2025-06-03 09:26:19 +08:00
committed by GitHub
parent c5e78fc7ad
commit 2a1585b32e
23 changed files with 58 additions and 148 deletions

View File

@ -6,6 +6,8 @@ package setting
import (
"testing"
"code.gitea.io/gitea/modules/test"
"github.com/stretchr/testify/assert"
)
@ -36,12 +38,8 @@ diff.algorithm = other
}
func TestGitReflog(t *testing.T) {
oldGit := Git
oldGitConfig := GitConfig
defer func() {
Git = oldGit
GitConfig = oldGitConfig
}()
defer test.MockVariableValue(&Git)
defer test.MockVariableValue(&GitConfig)
// default reflog config without legacy options
cfg, err := NewConfigProviderFromData(``)