Merged in bugfix/cleanup (pull request #10)
Clean Up Testing and Linting * somescriptcleanup * mostgolangci * deplatest * imageversions * usingscratch * movedqueuefrtesting * finishedunittesting * linting * taskfilecontext
This commit is contained in:
@@ -14,7 +14,12 @@ import (
|
||||
"github.com/testcontainers/testcontainers-go/wait"
|
||||
)
|
||||
|
||||
func createDB(t *testing.T, ctx context.Context) (*pgxpool.Pool, testcontainers.Container) {
|
||||
type db struct {
|
||||
pool *pgxpool.Pool
|
||||
container *testcontainers.Container
|
||||
}
|
||||
|
||||
func createDB(t *testing.T, ctx context.Context) (*db, func()) {
|
||||
port, err := nat.NewPort("tcp", "5432")
|
||||
if err != nil {
|
||||
t.Fatalf("Failed to create port: %v", err)
|
||||
@@ -25,7 +30,7 @@ func createDB(t *testing.T, ctx context.Context) (*pgxpool.Pool, testcontainers.
|
||||
user := "postgres"
|
||||
|
||||
req := testcontainers.ContainerRequest{
|
||||
Image: "postgres:latest",
|
||||
Image: "postgres:17.2-alpine3.21",
|
||||
Env: map[string]string{
|
||||
"POSTGRES_DB": name,
|
||||
"POSTGRES_USER": user,
|
||||
@@ -65,5 +70,13 @@ func createDB(t *testing.T, ctx context.Context) (*pgxpool.Pool, testcontainers.
|
||||
|
||||
pool := database.GetDBPool(ctx)
|
||||
|
||||
return pool, container
|
||||
return &db{
|
||||
pool: pool,
|
||||
container: &container,
|
||||
}, func() {
|
||||
err := container.Terminate(ctx)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user