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 // open db handler
testDB, err := db.OpenFromConnectionString("postgres", psql.ConnectionString()+"?sslmode=disable") testDB, err := db.OpenFromConnectionString("postgres", psql.ConnectionString()+"?sslmode=disable")
if err != nil { if err != nil {
psql.Shutdown(ctx)
panic(err) panic(err)
} }
if err = testDB.Setup(); err != nil { if err = testDB.Setup(); err != nil {
psql.Shutdown(ctx)
panic(err) panic(err)
} }
// start miniredis // start miniredis
r, err := miniredis.Run() r, err := miniredis.Run()
if err != nil { if err != nil {
psql.Shutdown(ctx)
panic(err) panic(err)
} }
// open redis handler // open redis handler
rh, err := redis.OpenRedis(r.Addr()) rh, err := redis.OpenRedis(r.Addr())
if err != nil { if err != nil {
psql.Shutdown(ctx)
panic(err) panic(err)
} }