fix(testing): Add lib/pq import and update postgres container setup

new version of testing library changed functions
This commit is contained in:
SoXX 2024-08-13 12:55:06 +02:00
parent 51b305a725
commit 89ab1dca02

View File

@ -15,6 +15,7 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
"gorm.io/gorm/logger" "gorm.io/gorm/logger"
_ "github.com/lib/pq"
"github.com/testcontainers/testcontainers-go" "github.com/testcontainers/testcontainers-go"
"github.com/testcontainers/testcontainers-go/wait" "github.com/testcontainers/testcontainers-go/wait"
) )
@ -28,8 +29,7 @@ const (
func StartPostgresContainer(ctx context.Context) (*postgrescontainer.PostgresContainer, *gorm.DB, error) { func StartPostgresContainer(ctx context.Context) (*postgrescontainer.PostgresContainer, *gorm.DB, error) {
pgContainer, err := postgrescontainer.RunContainer(ctx, pgContainer, err := postgrescontainer.Run(ctx, "postgres:alpine",
testcontainers.WithImage("postgres:alpine"),
postgrescontainer.WithDatabase(databaseName), postgrescontainer.WithDatabase(databaseName),
postgrescontainer.WithUsername(databaseUser), postgrescontainer.WithUsername(databaseUser),
postgrescontainer.WithPassword(databasePassword), postgrescontainer.WithPassword(databasePassword),