From 830942a920c3a67a907dd854761ce3b84bf5af6d Mon Sep 17 00:00:00 2001 From: carlocamurri Date: Fri, 23 Jun 2023 16:50:35 +0100 Subject: [PATCH] uncomment debug --- internal/common/database/db_testutil.go | 29 +++++++++++++------------ 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/internal/common/database/db_testutil.go b/internal/common/database/db_testutil.go index be0a1ab6589..1207080a5d0 100644 --- a/internal/common/database/db_testutil.go +++ b/internal/common/database/db_testutil.go @@ -2,6 +2,7 @@ package database import ( "context" + "fmt" "github.com/jackc/pgx/v4" "github.com/jackc/pgx/v4/pgxpool" @@ -38,20 +39,20 @@ func WithTestDb(migrations []Migration, action func(db *pgxpool.Pool) error) err return errors.WithStack(err) } - //defer func() { - // // disconnect all db user before cleanup - // _, err = db.Exec(ctx, - // `SELECT pg_terminate_backend(pg_stat_activity.pid) - // FROM pg_stat_activity WHERE pg_stat_activity.datname = '`+dbName+`';`) - // if err != nil { - // fmt.Println("Failed to disconnect users") - // } - // - // _, err = db.Exec(ctx, "DROP DATABASE "+dbName) - // if err != nil { - // fmt.Println("Failed to drop database") - // } - //}() + defer func() { + // disconnect all db user before cleanup + _, err = db.Exec(ctx, + `SELECT pg_terminate_backend(pg_stat_activity.pid) + FROM pg_stat_activity WHERE pg_stat_activity.datname = '`+dbName+`';`) + if err != nil { + fmt.Println("Failed to disconnect users") + } + + _, err = db.Exec(ctx, "DROP DATABASE "+dbName) + if err != nil { + fmt.Println("Failed to drop database") + } + }() err = UpdateDatabase(ctx, testDbPool, migrations) if err != nil {