Fix mssql integration tests by using custom database "gitea"
Signed-off-by: Jonas Franz <info@jonasfranz.software>
This commit is contained in:
parent
1c7c44fa05
commit
729a512723
2
Makefile
2
Makefile
|
@ -39,7 +39,7 @@ TEST_PGSQL_DBNAME ?= testgitea
|
|||
TEST_PGSQL_USERNAME ?= postgres
|
||||
TEST_PGSQL_PASSWORD ?= postgres
|
||||
TEST_MSSQL_HOST ?= mssql:1433
|
||||
TEST_MSSQL_DBNAME ?= master
|
||||
TEST_MSSQL_DBNAME ?= gitea
|
||||
TEST_MSSQL_USERNAME ?= sa
|
||||
TEST_MSSQL_PASSWORD ?= MwantsaSecurePassword1
|
||||
|
||||
|
|
|
@ -47,6 +47,8 @@ func TestMain(m *testing.M) {
|
|||
helper = &testfixtures.PostgreSQL{}
|
||||
} else if setting.UseSQLite3 {
|
||||
helper = &testfixtures.SQLite{}
|
||||
} else if setting.UseMSSQL {
|
||||
helper = &testfixtures.SQLServer{}
|
||||
} else {
|
||||
fmt.Println("Unsupported RDBMS for integration tests")
|
||||
os.Exit(1)
|
||||
|
@ -133,12 +135,12 @@ func initIntegrationTest() {
|
|||
case setting.UseMSSQL:
|
||||
host, port := models.ParseMSSQLHostPort(models.DbCfg.Host)
|
||||
db, err := sql.Open("mssql", fmt.Sprintf("server=%s; port=%s; database=%s; user id=%s; password=%s;",
|
||||
host, port, models.DbCfg.Name, models.DbCfg.User, models.DbCfg.Passwd))
|
||||
host, port, "master", models.DbCfg.User, models.DbCfg.Passwd))
|
||||
defer db.Close()
|
||||
if err != nil {
|
||||
log.Fatalf("sql.Open: %v", err)
|
||||
}
|
||||
if _, err := db.Exec("If(db_id(N'master') IS NULL) BEGIN CREATE DATABASE master; END;"); err != nil {
|
||||
if _, err := db.Exec("If(db_id(N'gitea') IS NULL) BEGIN CREATE DATABASE gitea; END;"); err != nil {
|
||||
log.Fatalf("db.Exec: %v", err)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user