(t *testing.T)
| 1824 | } |
| 1825 | |
| 1826 | func TestConnExecBatchWriteError(t *testing.T) { |
| 1827 | t.Parallel() |
| 1828 | |
| 1829 | ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second) |
| 1830 | defer cancel() |
| 1831 | |
| 1832 | config, err := pgconn.ParseConfig(os.Getenv("PGX_TEST_DATABASE")) |
| 1833 | require.NoError(t, err) |
| 1834 | |
| 1835 | var mockConn mockConnection |
| 1836 | writeLatency := 0 * time.Second |
| 1837 | config.DialFunc = func(ctx context.Context, network, address string) (net.Conn, error) { |
| 1838 | conn, err := net.Dial(network, address) |
| 1839 | mockConn = mockConnection{conn, &writeLatency} |
| 1840 | return mockConn, err |
| 1841 | } |
| 1842 | |
| 1843 | pgConn, err := pgconn.ConnectConfig(ctx, config) |
| 1844 | require.NoError(t, err) |
| 1845 | defer closeConn(t, pgConn) |
| 1846 | |
| 1847 | batch := &pgconn.Batch{} |
| 1848 | pgConn.Conn() |
| 1849 | |
| 1850 | ctx2, cancel2 := context.WithTimeout(context.Background(), 1*time.Second) |
| 1851 | defer cancel2() |
| 1852 | |
| 1853 | batch.ExecParams("select $1::text", [][]byte{[]byte("ExecParams 1")}, nil, nil, nil) |
| 1854 | writeLatency = 2 * time.Second |
| 1855 | mrr := pgConn.ExecBatch(ctx2, batch) |
| 1856 | err = mrr.Close() |
| 1857 | require.Error(t, err) |
| 1858 | assert.ErrorIs(t, err, context.DeadlineExceeded) |
| 1859 | require.True(t, pgConn.IsClosed()) |
| 1860 | } |
| 1861 | |
| 1862 | func TestConnExecBatchDeferredError(t *testing.T) { |
| 1863 | t.Parallel() |
nothing calls this directly
no test coverage detected