test: stop tests from writing into ~/.ssh (#39348)

This commit is contained in:
silverwind
2026-09-18 17:07:45 +08:00
committed by GitHub
parent 6400c1545e
commit db7dbd5a6b
+2
View File
@@ -121,6 +121,8 @@ func SetupGiteaTestEnv() {
panic("SetupGiteaTestEnv failed, paths are not initialized") panic("SetupGiteaTestEnv failed, paths are not initialized")
} }
SSH.RootPath = AppDataTempDir("ssh").JoinPath() // prevent tests from writing into ~/.ssh
// TODO: some git repo hooks (test fixtures) still use these env variables, need to be refactored in the future // TODO: some git repo hooks (test fixtures) still use these env variables, need to be refactored in the future
_ = os.Setenv("GITEA_ROOT", giteaRoot) _ = os.Setenv("GITEA_ROOT", giteaRoot)
_ = os.Setenv("GITEA_CONF", giteaConf) // test fixture git hooks use "$GITEA_ROOT/$GITEA_CONF" in their scripts _ = os.Setenv("GITEA_CONF", giteaConf) // test fixture git hooks use "$GITEA_ROOT/$GITEA_CONF" in their scripts