mirror of https://github.com/go-gorm/gorm.git
Fix tests script
This commit is contained in:
parent
9807fffdbc
commit
bc01eb28ad
|
@ -6,6 +6,11 @@ import (
|
|||
. "github.com/jinzhu/gorm/tests"
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
RunMigrations()
|
||||
m.Run()
|
||||
}
|
||||
|
||||
func TestExceptionsWithInvalidSql(t *testing.T) {
|
||||
var columns []string
|
||||
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 {
|
||||
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() {
|
||||
var err error
|
||||
if DB, err = OpenTestConnection(); err == nil {
|
||||
RunMigrations()
|
||||
} else {
|
||||
if DB, err = OpenTestConnection(); err != nil {
|
||||
log.Printf("failed to connect database, got error %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
|
|
@ -9,11 +9,17 @@ for dialect in "${dialects[@]}" ; do
|
|||
then
|
||||
echo "testing ${dialect}..."
|
||||
|
||||
race=""
|
||||
if [ "$GORM_VERBOSE" = "" ]
|
||||
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
|
||||
DEBUG=false GORM_DIALECT=${dialect} go test -race -count=1 -v ./...
|
||||
DEBUG=false GORM_DIALECT=${dialect} go test $race -count=1 -v ./...
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
|
Loading…
Reference in New Issue