aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_utils.go
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/test_utils.go
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/test_utils.go')
-rw-r--r--tests/test_utils.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/tests/test_utils.go b/tests/test_utils.go
index 5cc31b814e..e3e5becfbe 100644
--- a/tests/test_utils.go
+++ b/tests/test_utils.go
@@ -74,7 +74,7 @@ func InitTest(requireGitea bool) {
}
switch {
- case setting.Database.UseMySQL:
+ case setting.Database.Type.IsMySQL():
connType := "tcp"
if len(setting.Database.Host) > 0 && setting.Database.Host[0] == '/' { // looks like a unix socket
connType = "unix"
@@ -89,7 +89,7 @@ func InitTest(requireGitea bool) {
if _, err = db.Exec(fmt.Sprintf("CREATE DATABASE IF NOT EXISTS %s", setting.Database.Name)); err != nil {
log.Fatal("db.Exec: %v", err)
}
- case setting.Database.UsePostgreSQL:
+ case setting.Database.Type.IsPostgreSQL():
var db *sql.DB
var err error
if setting.Database.Host[0] == '/' {
@@ -146,7 +146,7 @@ func InitTest(requireGitea bool) {
}
}
- 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))