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

Function TestConnectCustomLookup

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

Source from the content-addressed store, hash-verified

579}
580
581func TestConnectCustomLookup(t *testing.T) {
582 t.Parallel()
583
584 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
585 defer cancel()
586
587 connString := os.Getenv("PGX_TEST_TCP_CONN_STRING")
588 if connString == "" {
589 t.Skipf("Skipping due to missing environment variable %v", "PGX_TEST_TCP_CONN_STRING")
590 }
591
592 config, err := pgconn.ParseConfig(connString)
593 require.NoError(t, err)
594
595 looked := false
596 config.LookupFunc = func(ctx context.Context, host string) (addrs []string, err error) {
597 looked = true
598 return net.LookupHost(host)
599 }
600
601 conn, err := pgconn.ConnectConfig(ctx, config)
602 require.NoError(t, err)
603 require.True(t, looked)
604 closeConn(t, conn)
605}
606
607func TestConnectCustomLookupWithPort(t *testing.T) {
608 t.Parallel()

Callers

nothing calls this directly

Calls 3

ParseConfigFunction · 0.92
ConnectConfigFunction · 0.92
closeConnFunction · 0.70

Tested by

no test coverage detected