ignore select for update tests

This commit is contained in:
Lunny Xiao 2019-02-01 11:26:55 +08:00
parent ee9ba59779
commit bbf9df9618
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
4 changed files with 20 additions and 12 deletions

View File

@ -54,8 +54,8 @@ jobs:
- run: go test -v -race -db="postgres" -conn_str="dbname=xorm_test sslmode=disable" -schema=xorm -cache=true -coverprofile=coverage5-2.txt -covermode=atomic - run: go test -v -race -db="postgres" -conn_str="dbname=xorm_test sslmode=disable" -schema=xorm -cache=true -coverprofile=coverage5-2.txt -covermode=atomic
- run: go test -v -race -db="mssql" -conn_str="server=localhost;user id=sa;password=yourStrong(!)Password;database=xorm_test" -coverprofile=coverage6-1.txt -covermode=atomic - run: go test -v -race -db="mssql" -conn_str="server=localhost;user id=sa;password=yourStrong(!)Password;database=xorm_test" -coverprofile=coverage6-1.txt -covermode=atomic
- run: go test -v -race -db="mssql" -conn_str="server=localhost;user id=sa;password=yourStrong(!)Password;database=xorm_test" -cache=true -coverprofile=coverage6-2.txt -covermode=atomic - run: go test -v -race -db="mssql" -conn_str="server=localhost;user id=sa;password=yourStrong(!)Password;database=xorm_test" -cache=true -coverprofile=coverage6-2.txt -covermode=atomic
- run: go test -v -race -db="mysql" -conn_str="root:@tcp(localhost:4000)/xorm_test" -coverprofile=coverage7-1.txt -covermode=atomic - run: go test -v -race -db="mysql" -conn_str="root:@tcp(localhost:4000)/xorm_test" -ignore_select_update=true -coverprofile=coverage7-1.txt -covermode=atomic
- run: go test -v -race -db="mysql" -conn_str="root:@tcp(localhost:4000)/xorm_test" -cache=true -coverprofile=coverage7-2.txt -covermode=atomic - run: go test -v -race -db="mysql" -conn_str="root:@tcp(localhost:4000)/xorm_test" -ignore_select_update=true -cache=true -coverprofile=coverage7-2.txt -covermode=atomic
- run: gocovmerge coverage1-1.txt coverage1-2.txt coverage2-1.txt coverage2-2.txt coverage3-1.txt coverage3-2.txt coverage4-1.txt coverage4-2.txt coverage5-1.txt coverage5-2.txt coverage6-1.txt coverage6-2.txt coverage7-1.txt coverage7-2.txt > coverage.txt - run: gocovmerge coverage1-1.txt coverage1-2.txt coverage2-1.txt coverage2-2.txt coverage3-1.txt coverage3-2.txt coverage4-1.txt coverage4-2.txt coverage5-1.txt coverage5-2.txt coverage6-1.txt coverage6-2.txt coverage7-1.txt coverage7-2.txt > coverage.txt
- run: bash <(curl -s https://codecov.io/bash) - run: bash <(curl -s https://codecov.io/bash)

View File

@ -110,7 +110,7 @@ func setupForUpdate(engine EngineInterface) error {
} }
func TestForUpdate(t *testing.T) { func TestForUpdate(t *testing.T) {
if testEngine.Dialect().DriverName() != "mysql" && testEngine.Dialect().DriverName() != "mymysql" { if *ignoreSelectUpdate {
return return
} }

View File

@ -1 +1 @@
go test -db=mysql -conn_str="root:@tcp(localhost:4000)/xorm_test" go test -db=mysql -conn_str="root:@tcp(localhost:4000)/xorm_test" -ignore_select_update=true

View File

@ -26,14 +26,15 @@ var (
dbType string dbType string
connString string connString string
db = flag.String("db", "sqlite3", "the tested database") db = flag.String("db", "sqlite3", "the tested database")
showSQL = flag.Bool("show_sql", true, "show generated SQLs") showSQL = flag.Bool("show_sql", true, "show generated SQLs")
ptrConnStr = flag.String("conn_str", "./test.db?cache=shared&mode=rwc", "test database connection string") ptrConnStr = flag.String("conn_str", "./test.db?cache=shared&mode=rwc", "test database connection string")
mapType = flag.String("map_type", "snake", "indicate the name mapping") mapType = flag.String("map_type", "snake", "indicate the name mapping")
cache = flag.Bool("cache", false, "if enable cache") cache = flag.Bool("cache", false, "if enable cache")
cluster = flag.Bool("cluster", false, "if this is a cluster") cluster = flag.Bool("cluster", false, "if this is a cluster")
splitter = flag.String("splitter", ";", "the splitter on connstr for cluster") splitter = flag.String("splitter", ";", "the splitter on connstr for cluster")
schema = flag.String("schema", "", "specify the schema") schema = flag.String("schema", "", "specify the schema")
ignoreSelectUpdate = flag.Bool("ignore_select_update", false, "ignore select update if implementation difference, only for tidb")
) )
func createEngine(dbType, connStr string) error { func createEngine(dbType, connStr string) error {
@ -51,6 +52,7 @@ func createEngine(dbType, connStr string) error {
return fmt.Errorf("db.Exec: %v", err) return fmt.Errorf("db.Exec: %v", err)
} }
db.Close() db.Close()
*ignoreSelectUpdate = true
case core.POSTGRES: case core.POSTGRES:
db, err := sql.Open(dbType, connStr) db, err := sql.Open(dbType, connStr)
if err != nil { if err != nil {
@ -73,6 +75,7 @@ func createEngine(dbType, connStr string) error {
} }
} }
db.Close() db.Close()
*ignoreSelectUpdate = true
case core.MYSQL: case core.MYSQL:
db, err := sql.Open(dbType, strings.Replace(connStr, "xorm_test", "mysql", -1)) db, err := sql.Open(dbType, strings.Replace(connStr, "xorm_test", "mysql", -1))
if err != nil { if err != nil {
@ -82,11 +85,16 @@ func createEngine(dbType, connStr string) error {
return fmt.Errorf("db.Exec: %v", err) return fmt.Errorf("db.Exec: %v", err)
} }
db.Close() db.Close()
default:
*ignoreSelectUpdate = true
} }
testEngine, err = NewEngine(dbType, connStr) testEngine, err = NewEngine(dbType, connStr)
} else { } else {
testEngine, err = NewEngineGroup(dbType, strings.Split(connStr, *splitter)) testEngine, err = NewEngineGroup(dbType, strings.Split(connStr, *splitter))
if dbType != "mysql" && dbType != "mymysql" {
*ignoreSelectUpdate = true
}
} }
if err != nil { if err != nil {
return err return err