fix ci
This commit is contained in:
parent
c2c3aab10a
commit
7ecdf5b255
|
@ -19,7 +19,7 @@ jobs:
|
|||
# CircleCI PostgreSQL images available at: https://hub.docker.com/r/circleci/postgres/
|
||||
- image: circleci/postgres:9.6.2-alpine
|
||||
environment:
|
||||
POSTGRES_USER: root
|
||||
POSTGRES_USER: circleci
|
||||
POSTGRES_DB: xorm_test
|
||||
|
||||
- image: microsoft/mssql-server-linux:latest
|
||||
|
|
12
xorm_test.go
12
xorm_test.go
|
@ -4,6 +4,7 @@ import (
|
|||
"database/sql"
|
||||
"flag"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -41,7 +42,7 @@ func createEngine(dbType, connStr string) error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
switch strings.ToUpper(dbType) {
|
||||
switch strings.ToLower(dbType) {
|
||||
case core.MSSQL:
|
||||
if _, err = db.Exec("If(db_id(N'xorm_test') IS NULL) BEGIN CREATE DATABASE xorm_test; END;"); err != nil {
|
||||
return fmt.Errorf("db.Exec: %v", err)
|
||||
|
@ -59,6 +60,11 @@ func createEngine(dbType, connStr string) error {
|
|||
if _, err = db.Exec("CREATE DATABASE xorm_test"); err != nil {
|
||||
return fmt.Errorf("db.Exec: %v", err)
|
||||
}
|
||||
if schema != nil {
|
||||
if _, err = db.Exec("CREATE SCHEMA " + *schema); err != nil {
|
||||
return fmt.Errorf("db.Exec: %v", err)
|
||||
}
|
||||
}
|
||||
case core.MYSQL:
|
||||
if _, err = db.Exec("CREATE DATABASE IF NOT EXISTS xorm_test"); err != nil {
|
||||
return fmt.Errorf("db.Exec: %v", err)
|
||||
|
@ -126,7 +132,7 @@ func TestMain(m *testing.M) {
|
|||
}
|
||||
} else {
|
||||
if ptrConnStr == nil {
|
||||
fmt.Println("you should indicate conn string")
|
||||
log.Fatal("you should indicate conn string")
|
||||
return
|
||||
}
|
||||
connString = *ptrConnStr
|
||||
|
@ -143,7 +149,7 @@ func TestMain(m *testing.M) {
|
|||
fmt.Println("testing", dbType, connString)
|
||||
|
||||
if err := prepareEngine(); err != nil {
|
||||
fmt.Println(err)
|
||||
log.Fatal(err)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue