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

Function tokio_postgres_extended_query_works

tests/client_compat.rs:17–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15
16#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
17async fn tokio_postgres_extended_query_works() -> Result<()> {
18 let server = PgliteServer::temporary_tcp()?;
19 let (client, connection) = tokio_postgres::connect(&server.connection_uri(), NoTls)
20 .await
21 .context("connect with tokio-postgres")?;
22 let connection_task = tokio::spawn(connection);
23
24 let row = client
25 .query_one("SELECT $1::int4 + 1 AS answer", &[&41_i32])
26 .await
27 .context("run tokio-postgres parameter query")?;
28 assert_eq!(row.get::<_, i32>("answer"), 42);
29
30 client
31 .batch_execute(
32 "CREATE TABLE items(value TEXT);
33 INSERT INTO items(value) VALUES ('alpha');",
34 )
35 .await?;
36 let row = client
37 .query_one("SELECT value FROM items WHERE value = $1", &[&"alpha"])
38 .await
39 .context("run tokio-postgres table query")?;
40 assert_eq!(row.get::<_, &str>(0), "alpha");
41
42 drop(client);
43 wait_for_tokio_postgres(connection_task).await?;
44 server.shutdown()?;
45 Ok(())
46}
47
48#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
49async fn tokio_postgres_extended_query_errors_recover_after_sync() -> Result<()> {

Callers

nothing calls this directly

Calls 3

wait_for_tokio_postgresFunction · 0.85
connection_uriMethod · 0.80
shutdownMethod · 0.45

Tested by

no test coverage detected