mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-23 07:40:10 +00:00
testutil: fix possible orphaned container in SetupEnvironment
This commit is contained in:
parent
556878544d
commit
261ea6505f
@ -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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user