postgres_test.go 625 B

1234567891011121314151617181920212223242526272829303132333435
  1. package postgres_test
  2. import (
  3. "fmt"
  4. "os"
  5. "testing"
  6. "github.com/jinzhu/gorm"
  7. "github.com/jinzhu/gorm/dialects/postgres"
  8. "github.com/jinzhu/gorm/tests"
  9. )
  10. var (
  11. DB *gorm.DB
  12. err error
  13. )
  14. func init() {
  15. dsn := "user=gorm password=gorm DB.name=gorm port=9920 sslmode=disable"
  16. if os.Getenv("GORM_DSN") != "" {
  17. dsn = os.Getenv("GORM_DSN")
  18. }
  19. if DB, err = gorm.Open(postgres.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. }