From 639691c0abfb80dd7d7989904b6d9e58d4af9f43 Mon Sep 17 00:00:00 2001 From: Lev Zakharov Date: Mon, 21 Aug 2023 15:24:57 +0300 Subject: [PATCH] add test for stdlib.OpenDBFromPool --- stdlib/sql_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/stdlib/sql_test.go b/stdlib/sql_test.go index aa8a613b..93265726 100644 --- a/stdlib/sql_test.go +++ b/stdlib/sql_test.go @@ -18,6 +18,7 @@ import ( "github.com/jackc/pgx/v5" "github.com/jackc/pgx/v5/pgconn" "github.com/jackc/pgx/v5/pgtype" + "github.com/jackc/pgx/v5/pgxpool" "github.com/jackc/pgx/v5/stdlib" "github.com/jackc/pgx/v5/tracelog" "github.com/stretchr/testify/assert" @@ -166,6 +167,17 @@ func TestSQLOpen(t *testing.T) { } } +func TestSQLOpenFromPool(t *testing.T) { + pool, err := pgxpool.New(context.Background(), os.Getenv("PGX_TEST_DATABASE")) + require.NoError(t, err) + t.Cleanup(pool.Close) + + db := stdlib.OpenDBFromPool(pool) + ensureDBValid(t, db) + + db.Close() +} + func TestNormalLifeCycle(t *testing.T) { db := openDB(t) defer closeDB(t, db)