testutil: fix possible orphaned container in SetupEnvironment

This commit is contained in:
CPunch 2024-02-01 17:25:11 -06:00
parent 556878544d
commit 261ea6505f

View File

@ -64,22 +64,26 @@ func SetupEnvironment(ctx context.Context) (*db.DBHandler, *redis.RedisHandler,
// open db handler
testDB, err := db.OpenFromConnectionString("postgres", psql.ConnectionString()+"?sslmode=disable")
if err != nil {
psql.Shutdown(ctx)
panic(err)
}
if err = testDB.Setup(); err != nil {
psql.Shutdown(ctx)
panic(err)
}
// start miniredis
r, err := miniredis.Run()
if err != nil {
psql.Shutdown(ctx)
panic(err)
}
// open redis handler
rh, err := redis.OpenRedis(r.Addr())
if err != nil {
psql.Shutdown(ctx)
panic(err)
}