style: rustfmt

This commit is contained in:
Ryan Leckey 2020-06-21 04:08:17 -07:00
parent 7c4c185698
commit 9abdd7e408
2 changed files with 17 additions and 8 deletions

View file

@ -17,11 +17,10 @@ where
Ok(DB::Connection::connect(&env::var("DATABASE_URL")?).await?)
}
// Make a new pool
// Ensure [dotenv] and [env_logger] have been setup
pub async fn pool<DB>() -> anyhow::Result<Pool<DB>>
where
where
DB: Database,
{
setup_if_needed();

View file

@ -1,7 +1,7 @@
use futures::TryStreamExt;
use sqlx::postgres::PgRow;
use sqlx::postgres::{PgDatabaseError, PgErrorPosition, PgSeverity};
use sqlx::{postgres::Postgres, Connection, Executor, Row, PgPool};
use sqlx::{postgres::Postgres, Connection, Executor, PgPool, Row};
use sqlx_test::new;
use std::time::Duration;
@ -150,11 +150,16 @@ async fn it_can_fail_and_recover() -> anyhow::Result<()> {
for i in 0..10 {
// make a query that will fail
let res = conn.execute("INSERT INTO not_found (column) VALUES (10)").await;
let res = conn
.execute("INSERT INTO not_found (column) VALUES (10)")
.await;
assert!(res.is_err());
// now try and use the connection
let val: i32 = conn.fetch_one(&*format!("SELECT {}::int4", i)).await?.get(0);
let val: i32 = conn
.fetch_one(&*format!("SELECT {}::int4", i))
.await?
.get(0);
assert_eq!(val, i);
}
@ -167,11 +172,16 @@ async fn it_can_fail_and_recover_with_pool() -> anyhow::Result<()> {
for i in 0..10 {
// make a query that will fail
let res = pool.execute("INSERT INTO not_found (column) VALUES (10)").await;
let res = pool
.execute("INSERT INTO not_found (column) VALUES (10)")
.await;
assert!(res.is_err());
// now try and use the connection
let val: i32 = pool.fetch_one(&*format!("SELECT {}::int4", i)).await?.get(0);
let val: i32 = pool
.fetch_one(&*format!("SELECT {}::int4", i))
.await?
.get(0);
assert_eq!(val, i);
}