mirror of
https://github.com/mattermost/mattermost.git
synced 2026-05-28 04:35:04 -04:00
fix default DSN for CI
This commit is contained in:
parent
a1e97a9e96
commit
e0e69cdbb0
1 changed files with 17 additions and 2 deletions
|
|
@ -10,6 +10,7 @@ import (
|
|||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"github.com/go-sql-driver/mysql"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
|
|
@ -48,12 +49,26 @@ func log(message string) {
|
|||
}
|
||||
}
|
||||
|
||||
func getDefaultMysqlDSN() string {
|
||||
if os.Getenv("IS_CI") == "true" {
|
||||
return strings.ReplaceAll(defaultMysqlDSN, "localhost", "mysql")
|
||||
}
|
||||
return defaultMysqlDSN
|
||||
}
|
||||
|
||||
func getDefaultPostgresqlDSN() string {
|
||||
if os.Getenv("IS_CI") == "true" {
|
||||
return strings.ReplaceAll(defaultPostgresqlDSN, "localhost", "postgres")
|
||||
}
|
||||
return defaultMysqlDSN
|
||||
}
|
||||
|
||||
// MySQLSettings returns the database settings to connect to the MySQL unittesting database.
|
||||
// The database name is generated randomly and must be created before use.
|
||||
func MySQLSettings(withReplica bool) *model.SqlSettings {
|
||||
dsn := os.Getenv("TEST_DATABASE_MYSQL_DSN")
|
||||
if dsn == "" {
|
||||
dsn = defaultMysqlDSN
|
||||
dsn = getDefaultMysqlDSN()
|
||||
mlog.Info("No TEST_DATABASE_MYSQL_DSN override, using default", mlog.String("default_dsn", dsn))
|
||||
} else {
|
||||
mlog.Info("Using TEST_DATABASE_MYSQL_DSN override", mlog.String("dsn", dsn))
|
||||
|
|
@ -85,7 +100,7 @@ func MySQLSettings(withReplica bool) *model.SqlSettings {
|
|||
func PostgreSQLSettings() *model.SqlSettings {
|
||||
dsn := os.Getenv("TEST_DATABASE_POSTGRESQL_DSN")
|
||||
if dsn == "" {
|
||||
dsn = defaultPostgresqlDSN
|
||||
dsn = getDefaultPostgresqlDSN()
|
||||
mlog.Info("No TEST_DATABASE_POSTGRESQL_DSN override, using default", mlog.String("default_dsn", dsn))
|
||||
} else {
|
||||
mlog.Info("Using TEST_DATABASE_POSTGRESQL_DSN override", mlog.String("dsn", dsn))
|
||||
|
|
|
|||
Loading…
Reference in a new issue