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

Function TestQueryEncodeError

query_test.go:576–597  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

574}
575
576func TestQueryEncodeError(t *testing.T) {
577 t.Parallel()
578
579 conn := mustConnectString(t, os.Getenv("PGX_TEST_DATABASE"))
580 defer closeConn(t, conn)
581
582 rows, err := conn.Query(context.Background(), "select $1::integer", "wrong")
583 if err != nil {
584 t.Errorf("conn.Query failure: %v", err)
585 }
586 assert.False(t, pgconn.SafeToRetry(err))
587 defer rows.Close()
588
589 rows.Next()
590
591 if rows.Err() == nil {
592 t.Error("Expected rows.Err() to return error, but it didn't")
593 }
594 if !strings.Contains(rows.Err().Error(), "SQLSTATE 22P02") {
595 t.Error("Expected rows.Err() to return different error:", rows.Err())
596 }
597}
598
599func TestQueryRowCoreTypes(t *testing.T) {
600 t.Parallel()

Callers

nothing calls this directly

Calls 8

SafeToRetryFunction · 0.92
mustConnectStringFunction · 0.85
closeConnFunction · 0.70
QueryMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.65
ErrMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected