Update tests

This commit is contained in:
Jinzhu 2019-06-13 11:21:13 +08:00
parent 321c636b9d
commit ff430cad49
1 changed files with 7 additions and 3 deletions

View File

@ -1,5 +1,9 @@
package gorm_test package gorm_test
// Run tests
// $ docker-compose up
// $ ./test_all.sh
import ( import (
"context" "context"
"database/sql" "database/sql"
@ -44,13 +48,13 @@ func OpenTestConnection() (db *gorm.DB, err error) {
case "mysql": case "mysql":
fmt.Println("testing mysql...") fmt.Println("testing mysql...")
if dbDSN == "" { if dbDSN == "" {
dbDSN = "gorm:gorm@tcp(localhost:3306)/gorm?charset=utf8&parseTime=True" dbDSN = "gorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True"
} }
db, err = gorm.Open("mysql", dbDSN) db, err = gorm.Open("mysql", dbDSN)
case "postgres": case "postgres":
fmt.Println("testing postgres...") fmt.Println("testing postgres...")
if dbDSN == "" { if dbDSN == "" {
dbDSN = "user=gorm password=gorm DB.name=gorm port=5432 sslmode=disable" dbDSN = "user=gorm password=gorm DB.name=gorm port=9920 sslmode=disable"
} }
db, err = gorm.Open("postgres", dbDSN) db, err = gorm.Open("postgres", dbDSN)
case "mssql": case "mssql":
@ -61,7 +65,7 @@ func OpenTestConnection() (db *gorm.DB, err error) {
// sp_changedbowner 'gorm'; // sp_changedbowner 'gorm';
fmt.Println("testing mssql...") fmt.Println("testing mssql...")
if dbDSN == "" { if dbDSN == "" {
dbDSN = "sqlserver://gorm:LoremIpsum86@localhost:1433?database=gorm" dbDSN = "sqlserver://gorm:LoremIpsum86@localhost:9930?database=gorm"
} }
db, err = gorm.Open("mssql", dbDSN) db, err = gorm.Open("mssql", dbDSN)
default: default: