2015-08-09 00:08:25 +03:00
|
|
|
package gorm_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestDdlErrors(t *testing.T) {
|
|
|
|
var err error
|
|
|
|
|
|
|
|
if err = DB.Close(); err != nil {
|
|
|
|
t.Errorf("Closing DDL test db connection err=%s", err)
|
|
|
|
}
|
|
|
|
defer func() {
|
|
|
|
// Reopen DB connection.
|
|
|
|
if DB, err = OpenTestConnection(); err != nil {
|
|
|
|
t.Fatalf("Failed re-opening db connection: %s", err)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2016-02-15 09:09:24 +03:00
|
|
|
if err := DB.Find(&User{}).Error; err == nil {
|
2015-08-09 00:08:25 +03:00
|
|
|
t.Errorf("Expected operation on closed db to produce an error, but err was nil")
|
|
|
|
}
|
|
|
|
}
|