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:
+8
-9
@@ -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())
|
||||
|
||||
Reference in New Issue
Block a user