clean up paths

This commit is contained in:
wxiaoguang
2026-04-25 21:41:52 +08:00
parent 1d6a95f80a
commit 09cf004306
4 changed files with 9 additions and 4 deletions

View File

@@ -12,6 +12,7 @@ import (
"code.gitea.io/gitea/modules/auth/password/hash"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/util"
)
var giteaTestSourceRoot *string
@@ -50,7 +51,11 @@ func SetupGiteaTestEnv() {
}
initGiteaPaths := func() {
StaticRootPath = *giteaTestSourceRoot // need to load assets (options, public) from the source code directory for testing
// need to load assets (options, public) from the source code directory for testing
StaticRootPath = *giteaTestSourceRoot
// during testing, the AppPath must point to the pre-built Gitea binary in the source root
// it needs to be called by git hooks
AppPath = filepath.Join(*giteaTestSourceRoot, "gitea") + util.Iif(IsWindows, ".exe", "")
}
initGiteaConf := func() string {

View File

@@ -95,7 +95,7 @@ func testMain(m *testing.M) int {
err = unittest.InitFixtures(
unittest.FixturesOptions{
Dir: filepath.Join(filepath.Dir(setting.AppPath), "models/fixtures/"),
Dir: filepath.Join(setting.GetGiteaTestSourceRoot(), "models/fixtures/"),
},
)
if err != nil {

View File

@@ -40,7 +40,7 @@ func initMigrationTest(t *testing.T) func() {
setting.SetupGiteaTestEnv()
assert.NotEmpty(t, setting.RepoRootPath)
assert.NoError(t, unittest.SyncDirs(filepath.Join(filepath.Dir(setting.AppPath), "tests/gitea-repositories-meta"), setting.RepoRootPath))
assert.NoError(t, unittest.SyncDirs(filepath.Join(setting.GetGiteaTestSourceRoot(), "tests/gitea-repositories-meta"), setting.RepoRootPath))
assert.NoError(t, git.InitFull())
setting.LoadDBSetting()
setting.InitLoggersForTest()

View File

@@ -156,7 +156,7 @@ func PrepareGitRepoDirectory(t testing.TB) {
if !assert.NotEmpty(t, setting.RepoRootPath) {
return
}
assert.NoError(t, unittest.SyncDirs(filepath.Join(filepath.Dir(setting.AppPath), "tests/gitea-repositories-meta"), setting.RepoRootPath))
assert.NoError(t, unittest.SyncDirs(filepath.Join(setting.GetGiteaTestSourceRoot(), "tests/gitea-repositories-meta"), setting.RepoRootPath))
}
func PrepareArtifactsStorage(t testing.TB) {