Pushing test db cleanup up to where the database objects are created using t.Cleanup. (#166)
This commit is contained in:
1 parent
316b250a24
commit
bb4a185412
25 files changed
+110
-793
No files matched your search
@@ -26,15 +26,7 @@ import (
|
||||
// Creates an org scoped group and a project scoped group.
|
||||
func createDefaultGroupsAndRepo(t *testing.T) (*iam.Group, *iam.Group, 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) {
|
||||
@@ -144,15 +136,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) {
|
||||
|
||||
@@ -26,15 +26,7 @@ import (
|
||||
func createDefaultHostCatalogAndRepo(t *testing.T) (*static.HostCatalog, *iam.Scope, func() (*static.Repository, error)) {
|
||||
t.Helper()
|
||||
require := require.New(t)
|
||||
cleanup, conn, _ := db.TestSetup(t, "postgres")
|
||||
t.Cleanup(func() {
|
||||
if err := conn.Close(); err != nil {
|
||||
t.Errorf("failed closing the gorm db: %v", err)
|
||||
}
|
||||
if err := cleanup(); err != nil {
|
||||
t.Errorf("failed to clean up TestSetup: %v", err)
|
||||
}
|
||||
})
|
||||
conn, _ := db.TestSetup(t, "postgres")
|
||||
_, pRes := iam.TestScopes(t, conn)
|
||||
|
||||
wrap := db.TestWrapper(t)
|
||||
|
||||
@@ -23,15 +23,7 @@ import (
|
||||
|
||||
func createDefaultOrganizationAndRepo(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) {
|
||||
@@ -112,15 +104,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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -25,15 +25,7 @@ import (
|
||||
|
||||
func createDefaultRolesAndRepo(t *testing.T) (*iam.Role, *iam.Role, 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) {
|
||||
@@ -143,15 +135,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) {
|
||||
|
||||
@@ -25,15 +25,7 @@ import (
|
||||
|
||||
func createDefaultUserAndRepo(t *testing.T) (*iam.User, 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) {
|
||||
@@ -110,15 +102,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) {
|
||||
|
||||
Reference in new issue
Block a user