2020-02-02 03:35:01 +03:00
|
|
|
package mysql_test
|
|
|
|
|
|
|
|
import (
|
2020-02-22 18:08:20 +03:00
|
|
|
"fmt"
|
2020-02-02 03:35:01 +03:00
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/jinzhu/gorm"
|
|
|
|
"github.com/jinzhu/gorm/dialects/mysql"
|
2020-02-22 18:08:20 +03:00
|
|
|
"github.com/jinzhu/gorm/tests"
|
2020-02-02 03:35:01 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestOpen(t *testing.T) {
|
|
|
|
gorm.Open(mysql.Open("gorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True"), nil)
|
|
|
|
}
|
2020-02-22 18:08:20 +03:00
|
|
|
|
|
|
|
var (
|
|
|
|
DB *gorm.DB
|
|
|
|
err error
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
if DB, err = gorm.Open(mysql.Open("gorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True"), &gorm.Config{}); err != nil {
|
|
|
|
panic(fmt.Sprintf("failed to initialize database, got error %v", err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestCURD(t *testing.T) {
|
|
|
|
tests.RunTestsSuit(t, DB)
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestMigrate(t *testing.T) {
|
|
|
|
tests.TestMigrate(t, DB)
|
|
|
|
}
|