MCPcopy
hub / github.com/jackc/pgx / TestConnectCustomDialer

Function TestConnectCustomDialer

pgconn/pgconn_test.go:560–579  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

558}
559
560func TestConnectCustomDialer(t *testing.T) {
561 t.Parallel()
562
563 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
564 defer cancel()
565
566 config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE"))
567 require.NoError(t, err)
568
569 dialed := false
570 config.DialFunc = func(ctx context.Context, network, address string) (net.Conn, error) {
571 dialed = true
572 return net.Dial(network, address)
573 }
574
575 conn, err := pgconn.ConnectConfig(ctx, config)
576 require.NoError(t, err)
577 require.True(t, dialed)
578 closeConn(t, conn)
579}
580
581func TestConnectCustomLookup(t *testing.T) {
582 t.Parallel()

Callers

nothing calls this directly

Calls 3

ParseConfigFunction · 0.92
ConnectConfigFunction · 0.92
closeConnFunction · 0.70

Tested by

no test coverage detected