mysql_test.go 616 B

1234567891011121314151617181920212223242526272829303132333435
  1. package mysql_test
  2. import (
  3. "fmt"
  4. "os"
  5. "testing"
  6. "github.com/jinzhu/gorm"
  7. "github.com/jinzhu/gorm/dialects/mysql"
  8. "github.com/jinzhu/gorm/tests"
  9. )
  10. var (
  11. DB *gorm.DB
  12. err error
  13. )
  14. func init() {
  15. dsn := "gorm:gorm@tcp(localhost:9910)/gorm?charset=utf8&parseTime=True"
  16. if os.Getenv("GORM_DSN") != "" {
  17. dsn = os.Getenv("GORM_DSN")
  18. }
  19. if DB, err = gorm.Open(mysql.Open(dsn), &gorm.Config{}); err != nil {
  20. panic(fmt.Sprintf("failed to initialize database, got error %v", err))
  21. }
  22. }
  23. func TestCURD(t *testing.T) {
  24. tests.RunTestsSuit(t, DB)
  25. }
  26. func TestMigrate(t *testing.T) {
  27. tests.TestMigrate(t, DB)
  28. }