summaryrefslogtreecommitdiffstats
path: root/tests/integration/migration-test
diff options
context:
space:
mode:
authorJason Song <i@wolfogre.com>2023-03-07 18:51:06 +0800
committerGitHub <noreply@github.com>2023-03-07 18:51:06 +0800
commitc84238800bb743181582f043ece9b44fef233c95 (patch)
tree83cf618233bb1a51c4a3325f8fa7662bb136afb1 /tests/integration/migration-test
parent84a299310d9a8f6387f18a1711485b7f33e6f6b5 (diff)
downloadgitea-c84238800bb743181582f043ece9b44fef233c95.tar.gz
gitea-c84238800bb743181582f043ece9b44fef233c95.zip
Refactor `setting.Database.UseXXX` to methods (#23354)
Replace #23350. Refactor `setting.Database.UseMySQL` to `setting.Database.Type.IsMySQL()`. To avoid mismatching between `Type` and `UseXXX`. This refactor can fix the bug mentioned in #23350, so it should be backported.
Diffstat (limited to 'tests/integration/migration-test')
-rw-r--r--tests/integration/migration-test/migration_test.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/integration/migration-test/migration_test.go b/tests/integration/migration-test/migration_test.go
index f030f566ce..4152379a9b 100644
--- a/tests/integration/migration-test/migration_test.go
+++ b/tests/integration/migration-test/migration_test.go
@@ -94,7 +94,7 @@ func availableVersions() ([]string, error) {
return nil, err
}
defer migrationsDir.Close()
- versionRE, err := regexp.Compile("gitea-v(?P<version>.+)\\." + regexp.QuoteMeta(setting.Database.Type) + "\\.sql.gz")
+ versionRE, err := regexp.Compile("gitea-v(?P<version>.+)\\." + regexp.QuoteMeta(setting.Database.Type.String()) + "\\.sql.gz")
if err != nil {
return nil, err
}
@@ -149,7 +149,7 @@ func restoreOldDB(t *testing.T, version string) bool {
}
switch {
- case setting.Database.UseSQLite3:
+ case setting.Database.Type.IsSQLite3():
util.Remove(setting.Database.Path)
err := os.MkdirAll(path.Dir(setting.Database.Path), os.ModePerm)
assert.NoError(t, err)
@@ -162,7 +162,7 @@ func restoreOldDB(t *testing.T, version string) bool {
assert.NoError(t, err)
db.Close()
- case setting.Database.UseMySQL:
+ case setting.Database.Type.IsMySQL():
db, err := sql.Open("mysql", fmt.Sprintf("%s:%s@tcp(%s)/",
setting.Database.User, setting.Database.Passwd, setting.Database.Host))
assert.NoError(t, err)
@@ -184,7 +184,7 @@ func restoreOldDB(t *testing.T, version string) bool {
assert.NoError(t, err)
db.Close()
- case setting.Database.UsePostgreSQL:
+ case setting.Database.Type.IsPostgreSQL():
var db *sql.DB
var err error
if setting.Database.Host[0] == '/' {
@@ -252,7 +252,7 @@ func restoreOldDB(t *testing.T, version string) bool {
assert.NoError(t, err)
db.Close()
- case setting.Database.UseMSSQL:
+ case setting.Database.Type.IsMSSQL():
host, port := setting.ParseMSSQLHostPort(setting.Database.Host)
db, err := sql.Open("mssql", fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;",
host, port, "master", setting.Database.User, setting.Database.Passwd))