Use DATABASE_URL env variable for query_tests

This commit is contained in:
Sam Samai 2021-07-31 16:38:12 +10:00
parent c240ebba77
commit 445d24eebf
2 changed files with 49 additions and 10 deletions

View File

@ -4,7 +4,6 @@ on:
push:
branches:
- master
- origin/ss/test_suite_refactor
pull_request:
branches:
- master

View File

@ -6,9 +6,14 @@ pub mod common;
pub use common::{bakery_chain::*, setup::*, TestContext};
#[async_std::test]
#[cfg(feature = "sqlx-mysql")]
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-sqlite",
feature = "sqlx-postgres"
))]
pub async fn find_one_with_no_result() {
let ctx = TestContext::new("mysql://root:@localhost", "find_one_with_no_result").await;
let ctx = TestContext::new("find_one_with_no_result").await;
let bakery = Bakery::find().one(&ctx.db).await.unwrap();
assert_eq!(bakery, None);
@ -17,9 +22,14 @@ pub async fn find_one_with_no_result() {
}
#[async_std::test]
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-sqlite",
feature = "sqlx-postgres"
))]
#[cfg(feature = "sqlx-mysql")]
pub async fn find_one_with_result() {
let ctx = TestContext::new("mysql://root:@localhost", "find_one_with_result").await;
let ctx = TestContext::new("find_one_with_result").await;
let bakery = bakery::ActiveModel {
name: Set("SeaSide Bakery".to_owned()),
@ -38,9 +48,14 @@ pub async fn find_one_with_result() {
}
#[async_std::test]
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-sqlite",
feature = "sqlx-postgres"
))]
#[cfg(feature = "sqlx-mysql")]
pub async fn find_by_id_with_no_result() {
let ctx = TestContext::new("mysql://root:@localhost", "find_by_id_with_no_result").await;
let ctx = TestContext::new("find_by_id_with_no_result").await;
let bakery = Bakery::find_by_id(999).one(&ctx.db).await.unwrap();
assert_eq!(bakery, None);
@ -49,9 +64,14 @@ pub async fn find_by_id_with_no_result() {
}
#[async_std::test]
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-sqlite",
feature = "sqlx-postgres"
))]
#[cfg(feature = "sqlx-mysql")]
pub async fn find_by_id_with_result() {
let ctx = TestContext::new("mysql://root:@localhost", "find_by_id_with_result").await;
let ctx = TestContext::new("find_by_id_with_result").await;
let bakery = bakery::ActiveModel {
name: Set("SeaSide Bakery".to_owned()),
@ -74,9 +94,14 @@ pub async fn find_by_id_with_result() {
}
#[async_std::test]
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-sqlite",
feature = "sqlx-postgres"
))]
#[cfg(feature = "sqlx-mysql")]
pub async fn find_all_with_no_result() {
let ctx = TestContext::new("mysql://root:@localhost", "find_all_with_no_result").await;
let ctx = TestContext::new("find_all_with_no_result").await;
let bakeries = Bakery::find().all(&ctx.db).await.unwrap();
assert_eq!(bakeries.len(), 0);
@ -85,9 +110,14 @@ pub async fn find_all_with_no_result() {
}
#[async_std::test]
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-sqlite",
feature = "sqlx-postgres"
))]
#[cfg(feature = "sqlx-mysql")]
pub async fn find_all_with_result() {
let ctx = TestContext::new("mysql://root:@localhost", "find_all_with_result").await;
let ctx = TestContext::new("find_all_with_result").await;
let _ = bakery::ActiveModel {
name: Set("SeaSide Bakery".to_owned()),
@ -115,9 +145,14 @@ pub async fn find_all_with_result() {
}
#[async_std::test]
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-sqlite",
feature = "sqlx-postgres"
))]
#[cfg(feature = "sqlx-mysql")]
pub async fn find_all_filter_no_result() {
let ctx = TestContext::new("mysql://root:@localhost", "find_all_filter_no_result").await;
let ctx = TestContext::new("find_all_filter_no_result").await;
let _ = bakery::ActiveModel {
name: Set("SeaSide Bakery".to_owned()),
@ -149,9 +184,14 @@ pub async fn find_all_filter_no_result() {
}
#[async_std::test]
#[cfg(any(
feature = "sqlx-mysql",
feature = "sqlx-sqlite",
feature = "sqlx-postgres"
))]
#[cfg(feature = "sqlx-mysql")]
pub async fn find_all_filter_with_results() {
let ctx = TestContext::new("mysql://root:@localhost", "find_all_filter_with_results").await;
let ctx = TestContext::new("find_all_filter_with_results").await;
let _ = bakery::ActiveModel {
name: Set("SeaSide Bakery".to_owned()),