forked from mirror/gorm
Fix tests script
This commit is contained in:
parent
9807fffdbc
commit
bc01eb28ad
|
@ -6,6 +6,11 @@ import (
|
||||||
. "github.com/jinzhu/gorm/tests"
|
. "github.com/jinzhu/gorm/tests"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
RunMigrations()
|
||||||
|
m.Run()
|
||||||
|
}
|
||||||
|
|
||||||
func TestExceptionsWithInvalidSql(t *testing.T) {
|
func TestExceptionsWithInvalidSql(t *testing.T) {
|
||||||
var columns []string
|
var columns []string
|
||||||
if DB.Where("sdsd.zaaa = ?", "sd;;;aa").Pluck("aaa", &columns).Error == nil {
|
if DB.Where("sdsd.zaaa = ?", "sd;;;aa").Pluck("aaa", &columns).Error == nil {
|
||||||
|
|
|
@ -25,7 +25,7 @@ func TestMigrate(t *testing.T) {
|
||||||
|
|
||||||
for _, m := range allModels {
|
for _, m := range allModels {
|
||||||
if !DB.Migrator().HasTable(m) {
|
if !DB.Migrator().HasTable(m) {
|
||||||
t.Fatalf("Failed to create table for %#v", m)
|
t.Fatalf("Failed to create table for %#v---", m)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,9 +19,7 @@ var DB *gorm.DB
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var err error
|
var err error
|
||||||
if DB, err = OpenTestConnection(); err == nil {
|
if DB, err = OpenTestConnection(); err != nil {
|
||||||
RunMigrations()
|
|
||||||
} else {
|
|
||||||
log.Printf("failed to connect database, got error %v\n", err)
|
log.Printf("failed to connect database, got error %v\n", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,17 @@ for dialect in "${dialects[@]}" ; do
|
||||||
then
|
then
|
||||||
echo "testing ${dialect}..."
|
echo "testing ${dialect}..."
|
||||||
|
|
||||||
|
race=""
|
||||||
if [ "$GORM_VERBOSE" = "" ]
|
if [ "$GORM_VERBOSE" = "" ]
|
||||||
then
|
then
|
||||||
DEBUG=false GORM_DIALECT=${dialect} go test -race -count=1 ./...
|
race="-race"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$GORM_VERBOSE" = "" ]
|
||||||
|
then
|
||||||
|
DEBUG=false GORM_DIALECT=${dialect} go test $race -count=1 ./...
|
||||||
else
|
else
|
||||||
DEBUG=false GORM_DIALECT=${dialect} go test -race -count=1 -v ./...
|
DEBUG=false GORM_DIALECT=${dialect} go test $race -count=1 -v ./...
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
Loading…
Reference in New Issue