Use DATABASE_URL env variable for query_tests
This commit is contained in:
parent
c240ebba77
commit
445d24eebf
1
.github/workflows/rust.yml
vendored
1
.github/workflows/rust.yml
vendored
@ -4,7 +4,6 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- origin/ss/test_suite_refactor
|
|
||||||
pull_request:
|
pull_request:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
@ -6,9 +6,14 @@ pub mod common;
|
|||||||
pub use common::{bakery_chain::*, setup::*, TestContext};
|
pub use common::{bakery_chain::*, setup::*, TestContext};
|
||||||
|
|
||||||
#[async_std::test]
|
#[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() {
|
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();
|
let bakery = Bakery::find().one(&ctx.db).await.unwrap();
|
||||||
assert_eq!(bakery, None);
|
assert_eq!(bakery, None);
|
||||||
@ -17,9 +22,14 @@ pub async fn find_one_with_no_result() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "sqlx-mysql",
|
||||||
|
feature = "sqlx-sqlite",
|
||||||
|
feature = "sqlx-postgres"
|
||||||
|
))]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
#[cfg(feature = "sqlx-mysql")]
|
||||||
pub async fn find_one_with_result() {
|
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 {
|
let bakery = bakery::ActiveModel {
|
||||||
name: Set("SeaSide Bakery".to_owned()),
|
name: Set("SeaSide Bakery".to_owned()),
|
||||||
@ -38,9 +48,14 @@ pub async fn find_one_with_result() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "sqlx-mysql",
|
||||||
|
feature = "sqlx-sqlite",
|
||||||
|
feature = "sqlx-postgres"
|
||||||
|
))]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
#[cfg(feature = "sqlx-mysql")]
|
||||||
pub async fn find_by_id_with_no_result() {
|
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();
|
let bakery = Bakery::find_by_id(999).one(&ctx.db).await.unwrap();
|
||||||
assert_eq!(bakery, None);
|
assert_eq!(bakery, None);
|
||||||
@ -49,9 +64,14 @@ pub async fn find_by_id_with_no_result() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "sqlx-mysql",
|
||||||
|
feature = "sqlx-sqlite",
|
||||||
|
feature = "sqlx-postgres"
|
||||||
|
))]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
#[cfg(feature = "sqlx-mysql")]
|
||||||
pub async fn find_by_id_with_result() {
|
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 {
|
let bakery = bakery::ActiveModel {
|
||||||
name: Set("SeaSide Bakery".to_owned()),
|
name: Set("SeaSide Bakery".to_owned()),
|
||||||
@ -74,9 +94,14 @@ pub async fn find_by_id_with_result() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "sqlx-mysql",
|
||||||
|
feature = "sqlx-sqlite",
|
||||||
|
feature = "sqlx-postgres"
|
||||||
|
))]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
#[cfg(feature = "sqlx-mysql")]
|
||||||
pub async fn find_all_with_no_result() {
|
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();
|
let bakeries = Bakery::find().all(&ctx.db).await.unwrap();
|
||||||
assert_eq!(bakeries.len(), 0);
|
assert_eq!(bakeries.len(), 0);
|
||||||
@ -85,9 +110,14 @@ pub async fn find_all_with_no_result() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "sqlx-mysql",
|
||||||
|
feature = "sqlx-sqlite",
|
||||||
|
feature = "sqlx-postgres"
|
||||||
|
))]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
#[cfg(feature = "sqlx-mysql")]
|
||||||
pub async fn find_all_with_result() {
|
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 {
|
let _ = bakery::ActiveModel {
|
||||||
name: Set("SeaSide Bakery".to_owned()),
|
name: Set("SeaSide Bakery".to_owned()),
|
||||||
@ -115,9 +145,14 @@ pub async fn find_all_with_result() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "sqlx-mysql",
|
||||||
|
feature = "sqlx-sqlite",
|
||||||
|
feature = "sqlx-postgres"
|
||||||
|
))]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
#[cfg(feature = "sqlx-mysql")]
|
||||||
pub async fn find_all_filter_no_result() {
|
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 {
|
let _ = bakery::ActiveModel {
|
||||||
name: Set("SeaSide Bakery".to_owned()),
|
name: Set("SeaSide Bakery".to_owned()),
|
||||||
@ -149,9 +184,14 @@ pub async fn find_all_filter_no_result() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
|
#[cfg(any(
|
||||||
|
feature = "sqlx-mysql",
|
||||||
|
feature = "sqlx-sqlite",
|
||||||
|
feature = "sqlx-postgres"
|
||||||
|
))]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
#[cfg(feature = "sqlx-mysql")]
|
||||||
pub async fn find_all_filter_with_results() {
|
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 {
|
let _ = bakery::ActiveModel {
|
||||||
name: Set("SeaSide Bakery".to_owned()),
|
name: Set("SeaSide Bakery".to_owned()),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user