aboutsummaryrefslogtreecommitdiffstats
path: root/integrations/migration-test/migration_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'integrations/migration-test/migration_test.go')
-rw-r--r--integrations/migration-test/migration_test.go28
1 files changed, 17 insertions, 11 deletions
diff --git a/integrations/migration-test/migration_test.go b/integrations/migration-test/migration_test.go
index 6fd7af832e..93b60e0e31 100644
--- a/integrations/migration-test/migration_test.go
+++ b/integrations/migration-test/migration_test.go
@@ -9,13 +9,13 @@ import (
"database/sql"
"fmt"
"io/ioutil"
- "log"
"os"
"path"
"regexp"
"sort"
"testing"
+ "code.gitea.io/gitea/integrations"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/migrations"
"code.gitea.io/gitea/modules/setting"
@@ -26,21 +26,22 @@ import (
var currentEngine *xorm.Engine
-func initMigrationTest() {
+func initMigrationTest(t *testing.T) {
+ integrations.PrintCurrentTest(t, 2)
giteaRoot := os.Getenv("GITEA_ROOT")
if giteaRoot == "" {
- fmt.Println("Environment variable $GITEA_ROOT not set")
+ integrations.Printf("Environment variable $GITEA_ROOT not set\n")
os.Exit(1)
}
setting.AppPath = path.Join(giteaRoot, "gitea")
if _, err := os.Stat(setting.AppPath); err != nil {
- fmt.Printf("Could not find gitea binary at %s\n", setting.AppPath)
+ integrations.Printf("Could not find gitea binary at %s\n", setting.AppPath)
os.Exit(1)
}
giteaConf := os.Getenv("GITEA_CONF")
if giteaConf == "" {
- fmt.Println("Environment variable $GITEA_CONF not set")
+ integrations.Printf("Environment variable $GITEA_CONF not set\n")
os.Exit(1)
} else if !path.IsAbs(giteaConf) {
setting.CustomConf = path.Join(giteaRoot, giteaConf)
@@ -51,6 +52,7 @@ func initMigrationTest() {
setting.NewContext()
setting.CheckLFSVersion()
models.LoadConfigs()
+ setting.NewLogServices(true)
}
func getDialect() string {
@@ -125,7 +127,7 @@ func restoreOldDB(t *testing.T, version string) bool {
data, err := readSQLFromFile(version)
assert.NoError(t, err)
if len(data) == 0 {
- log.Printf("No db found to restore for %s version: %s\n", models.DbCfg.Type, version)
+ integrations.Printf("No db found to restore for %s version: %s\n", models.DbCfg.Type, version)
return false
}
@@ -212,7 +214,8 @@ func wrappedMigrate(x *xorm.Engine) error {
}
func doMigrationTest(t *testing.T, version string) {
- log.Printf("Performing migration test for %s version: %s", models.DbCfg.Type, version)
+ integrations.PrintCurrentTest(t)
+ integrations.Printf("Performing migration test for %s version: %s\n", models.DbCfg.Type, version)
if !restoreOldDB(t, version) {
return
}
@@ -227,19 +230,22 @@ func doMigrationTest(t *testing.T, version string) {
}
func TestMigrations(t *testing.T) {
- initMigrationTest()
+ initMigrationTest(t)
dialect := models.DbCfg.Type
versions, err := availableVersions()
assert.NoError(t, err)
if len(versions) == 0 {
- log.Printf("No old database versions available to migration test for %s\n", dialect)
+ integrations.Printf("No old database versions available to migration test for %s\n", dialect)
return
}
- log.Printf("Preparing to test %d migrations for %s\n", len(versions), dialect)
+ integrations.Printf("Preparing to test %d migrations for %s\n", len(versions), dialect)
for _, version := range versions {
- doMigrationTest(t, version)
+ t.Run(fmt.Sprintf("Migrate-%s-%s", dialect, version), func(t *testing.T) {
+ doMigrationTest(t, version)
+ })
+
}
}