database testing: do not use regular DB name for DB testing but only dummy DB

This commit is contained in:
Sonja Happ 2019-09-03 17:19:44 +02:00
parent 6221f7d851
commit 69c299215c

View file

@ -18,19 +18,18 @@ func fM(s string, id uint) string {
func TestMain(m *testing.M) { func TestMain(m *testing.M) {
db = DummyInitDB() db = DummyInitDB()
defer db.Close()
// Verify that you can connect to the database
err := db.DB().Ping()
if err != nil {
fmt.Println("Error: DB must ping to run tests")
return
}
defer db.Close()
os.Exit(m.Run()) os.Exit(m.Run())
} }
// Verify that you can connect to the database
func TestDBConnection(t *testing.T) {
db := InitDB()
defer db.Close()
assert.NoError(t, VerifyConnection(db), "DB must ping")
}
func TestUserAssociations(t *testing.T) { func TestUserAssociations(t *testing.T) {
DropTables(db) DropTables(db)