Pushing test db cleanup up to where the database objects are created using t.Cleanup. (#166)

This commit is contained in:
Todd Knight authored and GitHub committed 2020-07-06 10:15:01 -07:00
1 parent 316b250a24
commit bb4a185412
25 files changed
+110 -793

No files matched your search

@@ -26,15 +26,7 @@ import (
func createDefaultProjectAndRepo(t *testing.T) (*iam.Scope, func() (*iam.Repository, error)) {
t.Helper()
cleanup, conn, _ := db.TestSetup(t, "postgres")
t.Cleanup(func() {
if err := conn.Close(); err != nil {
t.Errorf("Error when closing gorm DB: %v", err)
}
if err := cleanup(); err != nil {
t.Errorf("Error when cleaning up TestSetup: %v", err)
}
})
conn, _ := db.TestSetup(t, "postgres")
rw := db.New(conn)
wrap := db.TestWrapper(t)
repoFn := func() (*iam.Repository, error) {
@@ -116,15 +108,7 @@ func TestGet(t *testing.T) {
func TestList(t *testing.T) {
assert, require := assert.New(t), require.New(t)
cleanup, conn, _ := db.TestSetup(t, "postgres")
t.Cleanup(func() {
if err := conn.Close(); err != nil {
t.Errorf("Error when closing gorm DB: %v", err)
}
if err := cleanup(); err != nil {
t.Errorf("Error when cleaning up TestSetup: %v", err)
}
})
conn, _ := db.TestSetup(t, "postgres")
rw := db.New(conn)
wrap := db.TestWrapper(t)
repoFn := func() (*iam.Repository, error) {