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