mirror of https://github.com/jackc/pgx.git
Test getSharedConnection handles dead connections
If a test does something that kills a connection, it previously would break all subsequent tests that used the shared connection. It no longer does.pgx-vs-pq
parent
c36c0875c9
commit
c96fa440cc
|
@ -11,7 +11,7 @@ type test interface {
|
||||||
var sharedConnection *pgx.Connection
|
var sharedConnection *pgx.Connection
|
||||||
|
|
||||||
func getSharedConnection(t test) (c *pgx.Connection) {
|
func getSharedConnection(t test) (c *pgx.Connection) {
|
||||||
if sharedConnection == nil {
|
if sharedConnection == nil || !sharedConnection.IsAlive() {
|
||||||
var err error
|
var err error
|
||||||
sharedConnection, err = pgx.Connect(*defaultConnectionParameters)
|
sharedConnection, err = pgx.Connect(*defaultConnectionParameters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue