This commit is contained in:
wxiaoguang
2026-04-25 18:01:34 +08:00
parent a973269a37
commit 11f910c80c
4 changed files with 5 additions and 11 deletions

View File

@@ -204,7 +204,7 @@ func mainTest(m *testing.M) int {
testlogger.Init()
setting.SetupGiteaTestEnv()
tmpDataPath, cleanup, err := tempdir.OsTempDir("gitea-test").MkdirTempRandom("data")
tmpDataPath, cleanup, err := tempdir.OsTempDir("gitea-test").MkdirTempRandom("migration-test-data-")
if err != nil {
testlogger.Panicf("Unable to create temporary data path %v\n", err)
}

View File

@@ -15,7 +15,6 @@ import (
"code.gitea.io/gitea/models/system"
"code.gitea.io/gitea/modules/cache"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/setting/config"
"code.gitea.io/gitea/modules/storage"
@@ -44,7 +43,7 @@ func MainTest(m *testing.M, testOptsArg ...*TestOptions) {
func mainTest(m *testing.M, testOptsArg ...*TestOptions) int {
testOpts := util.OptionalArg(testOptsArg, &TestOptions{})
appDataPath, appDataCleanup, err := tempdir.OsTempDir("gitea-test").MkdirTempRandom("appdata")
appDataPath, appDataCleanup, err := tempdir.OsTempDir("gitea-test").MkdirTempRandom("unit-test-data-")
if err != nil {
testlogger.Panicf("TempDir: %v\n", err)
}
@@ -59,9 +58,6 @@ APP_DATA_PATH = `+appDataPath+`
os.Exit(1)
}
_, _ = fmt.Fprintf(os.Stderr, "mainTest: appDataPath=%s\n%s\n", appDataPath, log.Stack(2))
log.Error("mainTest: appDataPath=%s\n%s\n", appDataPath, log.Stack(2))
giteaRoot := setting.GetGiteaTestSourceRoot()
fixturesOpts := FixturesOptions{Dir: filepath.Join(giteaRoot, "models", "fixtures"), Files: testOpts.FixtureFiles}
if err := CreateTestEngine(fixturesOpts); err != nil {

View File

@@ -8,16 +8,11 @@ import (
"testing"
"code.gitea.io/gitea/modules/setting"
"github.com/stretchr/testify/assert"
)
func TestManager(t *testing.T) {
oldAppDataPath := setting.AppDataPath
setting.AppDataPath = t.TempDir()
defer func() {
setting.AppDataPath = oldAppDataPath
}()
newQueueFromConfig := func(name, cfg string) (*WorkerPoolQueue[int], error) {
cfgProvider, err := setting.NewConfigProviderFromData(cfg)

View File

@@ -278,6 +278,9 @@ func loadServerFrom(rootCfg ConfigProvider) {
StaticRootPath = sec.Key("STATIC_ROOT_PATH").MustString(StaticRootPath)
StaticCacheTime = sec.Key("STATIC_CACHE_TIME").MustDuration(6 * time.Hour)
AppDataPath = sec.Key("APP_DATA_PATH").MustString(filepath.Join(AppWorkPath, "data"))
log.Error("Set AppDataPath=%s\n%s\n", AppDataPath, log.Stack(2))
if !filepath.IsAbs(AppDataPath) {
AppDataPath = filepath.ToSlash(filepath.Join(AppWorkPath, AppDataPath))
}