(t *testing.T)
| 1543 | } |
| 1544 | |
| 1545 | func TestConnExecPreparedCanceled(t *testing.T) { |
| 1546 | t.Parallel() |
| 1547 | |
| 1548 | ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) |
| 1549 | defer cancel() |
| 1550 | |
| 1551 | pgConn, err := pgconn.Connect(ctx, os.Getenv("PGX_TEST_DATABASE")) |
| 1552 | require.NoError(t, err) |
| 1553 | defer closeConn(t, pgConn) |
| 1554 | |
| 1555 | _, err = pgConn.Prepare(ctx, "ps1", "select current_database(), pg_sleep(1)", nil) |
| 1556 | require.NoError(t, err) |
| 1557 | |
| 1558 | ctx, cancel = context.WithTimeout(ctx, 100*time.Millisecond) |
| 1559 | defer cancel() |
| 1560 | result := pgConn.ExecPrepared(ctx, "ps1", nil, nil, nil) |
| 1561 | rowCount := 0 |
| 1562 | for result.NextRow() { |
| 1563 | rowCount += 1 |
| 1564 | } |
| 1565 | assert.Equal(t, 0, rowCount) |
| 1566 | commandTag, err := result.Close() |
| 1567 | assert.Equal(t, pgconn.CommandTag{}, commandTag) |
| 1568 | assert.True(t, pgconn.Timeout(err)) |
| 1569 | assert.True(t, pgConn.IsClosed()) |
| 1570 | select { |
| 1571 | case <-pgConn.CleanupDone(): |
| 1572 | case <-time.After(5 * time.Second): |
| 1573 | t.Fatal("Connection cleanup exceeded maximum time") |
| 1574 | } |
| 1575 | } |
| 1576 | |
| 1577 | func TestConnExecPreparedPrecanceled(t *testing.T) { |
| 1578 | t.Parallel() |
nothing calls this directly
no test coverage detected