diff options
author | kolaente <konrad@kola-entertainments.de> | 2018-12-12 02:01:41 +0100 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2018-12-12 09:01:41 +0800 |
commit | 6db7dbd333204bcff50716e4840deee28e09c2f9 (patch) | |
tree | b68ee709873a91738b586fa57b367b2b217b0a4a /integrations/integration_test.go | |
parent | b1f3685015246d3458f6d8c1d892eab076b3ed4a (diff) | |
download | gitea-6db7dbd333204bcff50716e4840deee28e09c2f9.tar.gz gitea-6db7dbd333204bcff50716e4840deee28e09c2f9.zip |
Added test environment for mssql (#4282)
* Added test environment for m$sql
* Added template for test environment for m$sql
* Fix password
* Fix password (again)
* Fix password (again again)
* Fix db
* Ci trigger (Looking at you drone....)
* Ci trigger (Looking at you drone....)
* Ci trigger (Looking at you drone....)
* Ci trigger (Looking at you drone....)
* Create master database for mssql integration tests
Signed-off-by: Jonas Franz <info@jonasfranz.software>
* Create database only if master do not exist
Signed-off-by: Jonas Franz <info@jonasfranz.software>
* Fix mssql integration tests by using custom database "gitea"
Signed-off-by: Jonas Franz <info@jonasfranz.software>
* Moved defer
* bump xorm
* updated xorm
* Fixed build
Diffstat (limited to 'integrations/integration_test.go')
-rw-r--r-- | integrations/integration_test.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/integrations/integration_test.go b/integrations/integration_test.go index ed165f6534..25f6cff27c 100644 --- a/integrations/integration_test.go +++ b/integrations/integration_test.go @@ -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) @@ -130,6 +132,17 @@ func initIntegrationTest() { if _, err = db.Exec("CREATE DATABASE testgitea"); err != nil { log.Fatalf("db.Exec: %v", err) } + 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, "master", models.DbCfg.User, models.DbCfg.Passwd)) + if err != nil { + log.Fatalf("sql.Open: %v", err) + } + if _, err := db.Exec("If(db_id(N'gitea') IS NULL) BEGIN CREATE DATABASE gitea; END;"); err != nil { + log.Fatalf("db.Exec: %v", err) + } + defer db.Close() } routers.GlobalInit() } |