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

Function TestExecFailure

conn_test.go:279–296  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

277}
278
279func TestExecFailure(t *testing.T) {
280 t.Parallel()
281
282 ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
283 defer cancel()
284
285 pgxtest.RunWithQueryExecModes(ctx, t, defaultConnTestRunner, nil, func(ctx context.Context, t testing.TB, conn *pgx.Conn) {
286 if _, err := conn.Exec(context.Background(), "selct;"); err == nil {
287 t.Fatal("Expected SQL syntax error")
288 }
289
290 rows, _ := conn.Query(context.Background(), "select 1")
291 rows.Close()
292 if rows.Err() != nil {
293 t.Fatalf("Exec failure appears to have broken connection: %v", rows.Err())
294 }
295 })
296}
297
298func TestExecFailureWithArguments(t *testing.T) {
299 t.Parallel()

Callers

nothing calls this directly

Calls 5

RunWithQueryExecModesFunction · 0.92
ExecMethod · 0.65
QueryMethod · 0.65
CloseMethod · 0.65
ErrMethod · 0.65

Tested by

no test coverage detected