Skip to content

Commit

Permalink
uncomment debug
Browse files Browse the repository at this point in the history
  • Loading branch information
carlocamurri committed Jun 23, 2023
1 parent 61ce1c4 commit 830942a
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions internal/common/database/db_testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package database

import (
"context"
"fmt"

"github.com/jackc/pgx/v4"
"github.com/jackc/pgx/v4/pgxpool"
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 830942a

Please sign in to comment.