fix tests/mysql-macros.rs

This commit is contained in:
Austin Bonander 2020-01-28 19:53:17 -08:00
parent 140d9cb061
commit 02075c74bd

View file

@ -1,3 +1,5 @@
use sqlx::MySqlConnection;
#[cfg_attr(feature = "runtime-async-std", async_std::test)]
#[cfg_attr(feature = "runtime-tokio", tokio::test)]
async fn macro_select_from_cte() -> anyhow::Result<()> {
@ -43,7 +45,7 @@ async fn test_query_as_raw() -> anyhow::Result<()> {
let account = sqlx::query_as!(
RawAccount,
"SELECT * from (VALUES (1, null)) accounts(type, name)"
"SELECT * from (select 1 as type, cast(null as char) as name) accounts"
)
.fetch_one(&mut conn)
.await?;
@ -55,3 +57,11 @@ async fn test_query_as_raw() -> anyhow::Result<()> {
Ok(())
}
fn url() -> anyhow::Result<String> {
Ok(dotenv::var("DATABASE_URL")?)
}
async fn connect() -> anyhow::Result<MySqlConnection> {
Ok(MySqlConnection::open(url()?).await?)
}