PostgreSQL: Remove feature toggle postgresDSUsePGX (#113675)

* PostgreSQL: Remove feature toggle `postgresDSUsePGX`

* Fix tests and linting

* Address review comments
This commit is contained in:
Zoltán Bedi
2025-11-24 10:26:41 +01:00
committed by GitHub
parent 39dc659ad8
commit 8d75d79313
34 changed files with 1176 additions and 5165 deletions
@@ -1,12 +1,11 @@
package postgres
import (
"database/sql"
"fmt"
"net"
"testing"
"github.com/lib/pq"
"github.com/jackc/pgx/v5/pgxpool"
"github.com/stretchr/testify/require"
"golang.org/x/net/proxy"
)
@@ -25,15 +24,17 @@ func TestPostgresProxyDriver(t *testing.T) {
cnnstr := fmt.Sprintf("postgres://auser:password@%s/db?sslmode=disable", dbURL)
t.Run("Connector should use dialer context that routes through the socks proxy to db", func(t *testing.T) {
connector, err := pq.NewConnector(cnnstr)
config, err := pgxpool.ParseConfig(cnnstr)
require.NoError(t, err)
dialer := newPostgresProxyDialer(&testDialer{})
connector.Dialer(dialer)
config.ConnConfig.DialFunc = newDialFunc(&testDialer{})
db := sql.OpenDB(connector)
err = db.Ping()
pool, err := pgxpool.NewWithConfig(t.Context(), config)
require.NoError(t, err)
defer pool.Close()
err = pool.Ping(t.Context())
require.Error(t, err)
require.Contains(t, err.Error(), "test-dialer is not functional")
})
}