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 authored and GitHub committed 2025-06-03 01:26:19 +00:00
1 parent c5e78fc7ad
commit 2a1585b32e
23 files changed
+58 -148

No files matched your search

+4 -6
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(``)