MCPcopy Create free account
hub / github.com/f0rr0/oliphaunt / tokio_postgres_prepared_statement_reuse_works

Function tokio_postgres_prepared_statement_reuse_works

tests/client_compat.rs:593–610  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

591
592#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
593async fn tokio_postgres_prepared_statement_reuse_works() -> Result<()> {
594 let server = PgliteServer::temporary_tcp()?;
595 let (client, connection) = tokio_postgres::connect(&server.connection_uri(), NoTls)
596 .await
597 .context("connect with tokio-postgres")?;
598 let connection_task = tokio::spawn(connection);
599
600 let statement = client.prepare("SELECT $1::int4 + $2::int4 AS sum").await?;
601 for value in [1_i32, 10, 40] {
602 let row = client.query_one(&statement, &[&value, &2_i32]).await?;
603 assert_eq!(row.get::<_, i32>("sum"), value + 2);
604 }
605
606 drop(client);
607 wait_for_tokio_postgres(connection_task).await?;
608 server.shutdown()?;
609 Ok(())
610}
611
612#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
613async fn sqlx_transaction_error_recovers_after_rollback() -> Result<()> {

Callers

nothing calls this directly

Calls 4

wait_for_tokio_postgresFunction · 0.85
connection_uriMethod · 0.80
prepareMethod · 0.80
shutdownMethod · 0.45

Tested by

no test coverage detected