(t *testing.T)
| 326 | } |
| 327 | |
| 328 | func TestPoolAfterConnect(t *testing.T) { |
| 329 | t.Parallel() |
| 330 | |
| 331 | ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) |
| 332 | defer cancel() |
| 333 | |
| 334 | config, err := pgxpool.ParseConfig(os.Getenv("PGX_TEST_DATABASE")) |
| 335 | require.NoError(t, err) |
| 336 | |
| 337 | config.AfterConnect = func(ctx context.Context, c *pgx.Conn) error { |
| 338 | _, err := c.Prepare(ctx, "ps1", "select 1") |
| 339 | return err |
| 340 | } |
| 341 | |
| 342 | db, err := pgxpool.NewWithConfig(ctx, config) |
| 343 | require.NoError(t, err) |
| 344 | defer db.Close() |
| 345 | |
| 346 | var n int32 |
| 347 | err = db.QueryRow(ctx, "ps1").Scan(&n) |
| 348 | require.NoError(t, err) |
| 349 | assert.EqualValues(t, 1, n) |
| 350 | } |
| 351 | |
| 352 | func TestPoolBeforeAcquire(t *testing.T) { |
| 353 | t.Parallel() |
nothing calls this directly
no test coverage detected