Refactor integration tests infrastructure (#37462)

Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwind
2026-04-29 18:37:38 +02:00
committed by GitHub
parent 9262803621
commit d57d06335d
26 changed files with 331 additions and 544 deletions
+8 -9
View File
@@ -6,7 +6,6 @@ package tests
import (
"database/sql"
"fmt"
"os"
"path/filepath"
"strings"
"testing"
@@ -25,17 +24,14 @@ import (
"github.com/stretchr/testify/assert"
)
func InitTest() error {
func InitIntegrationTest() error {
testlogger.Init()
if os.Getenv("GITEA_TEST_CONF") == "" {
// By default, use sqlite.ini for testing, then IDE like GoLand can start the test process with debugger.
// It's easier for developers to debug bugs step by step with a debugger.
// Notice: when doing "ssh push", Gitea executes sub processes, debugger won't work for the sub processes.
giteaConf := "tests/sqlite.ini"
_ = os.Setenv("GITEA_TEST_CONF", giteaConf)
_, _ = fmt.Fprintf(os.Stderr, "Environment variable GITEA_TEST_CONF not set - defaulting to %s\n", giteaConf)
err := setting.PrepareIntegrationTestConfig()
if err != nil {
return err
}
setting.SetupGiteaTestEnv()
setting.Repository.DefaultBranch = "master" // many test code still assume that default branch is called "master"
@@ -132,6 +128,9 @@ func InitTest() error {
return err
}
}
case setting.Database.Type.IsSQLite3():
default:
return fmt.Errorf("unsupported database type: %s", setting.Database.Type)
}
routers.InitWebInstalled(graceful.GetManager().HammerContext())