Use DATABASE_URL env variable for bakery_chain_tests
This commit is contained in:
parent
445d24eebf
commit
1c3e1b410b
@ -5,16 +5,18 @@ pub use common::{bakery_chain::*, setup::*, TestContext};
|
|||||||
|
|
||||||
mod crud;
|
mod crud;
|
||||||
|
|
||||||
// cargo test --test bakery_chain_tests -- --nocapture
|
// Run the test locally:
|
||||||
|
// DATABASE_URL="mysql://root:@localhost" cargo test --features sqlx-mysql --test bakery_chain_tests
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
#[cfg(any(
|
||||||
|
feature = "sqlx-mysql",
|
||||||
|
feature = "sqlx-sqlite",
|
||||||
|
feature = "sqlx-postgres"
|
||||||
|
))]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let base_url = "mysql://root:@localhost";
|
let ctx = TestContext::new("bakery_chain_schema_crud_tests").await;
|
||||||
let db_name = "bakery_chain_schema_crud_tests";
|
create_entities(&ctx.db).await;
|
||||||
|
ctx.delete().await;
|
||||||
let db: DatabaseConnection = common::setup::setup(base_url, db_name).await;
|
|
||||||
create_entities(&db).await;
|
|
||||||
common::setup::tear_down(base_url, db_name).await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn create_entities(db: &DatabaseConnection) {
|
async fn create_entities(db: &DatabaseConnection) {
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
// cargo test --test query_tests -- --nocapture
|
|
||||||
use sea_orm::entity::*;
|
use sea_orm::entity::*;
|
||||||
use sea_orm::QueryFilter;
|
use sea_orm::QueryFilter;
|
||||||
|
|
||||||
pub mod common;
|
pub mod common;
|
||||||
pub use common::{bakery_chain::*, setup::*, TestContext};
|
pub use common::{bakery_chain::*, setup::*, TestContext};
|
||||||
|
|
||||||
|
// Run the test locally:
|
||||||
|
// DATABASE_URL="mysql://root:@localhost" cargo test --features sqlx-mysql --test query_tests
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
feature = "sqlx-mysql",
|
feature = "sqlx-mysql",
|
||||||
feature = "sqlx-sqlite",
|
feature = "sqlx-sqlite",
|
||||||
feature = "sqlx-postgres"
|
feature = "sqlx-postgres"
|
||||||
))]
|
))]
|
||||||
|
|
||||||
pub async fn find_one_with_no_result() {
|
pub async fn find_one_with_no_result() {
|
||||||
let ctx = TestContext::new("find_one_with_no_result").await;
|
let ctx = TestContext::new("find_one_with_no_result").await;
|
||||||
|
|
||||||
@ -27,7 +27,6 @@ pub async fn find_one_with_no_result() {
|
|||||||
feature = "sqlx-sqlite",
|
feature = "sqlx-sqlite",
|
||||||
feature = "sqlx-postgres"
|
feature = "sqlx-postgres"
|
||||||
))]
|
))]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
|
||||||
pub async fn find_one_with_result() {
|
pub async fn find_one_with_result() {
|
||||||
let ctx = TestContext::new("find_one_with_result").await;
|
let ctx = TestContext::new("find_one_with_result").await;
|
||||||
|
|
||||||
@ -53,7 +52,6 @@ pub async fn find_one_with_result() {
|
|||||||
feature = "sqlx-sqlite",
|
feature = "sqlx-sqlite",
|
||||||
feature = "sqlx-postgres"
|
feature = "sqlx-postgres"
|
||||||
))]
|
))]
|
||||||
#[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("find_by_id_with_no_result").await;
|
let ctx = TestContext::new("find_by_id_with_no_result").await;
|
||||||
|
|
||||||
@ -69,7 +67,6 @@ pub async fn find_by_id_with_no_result() {
|
|||||||
feature = "sqlx-sqlite",
|
feature = "sqlx-sqlite",
|
||||||
feature = "sqlx-postgres"
|
feature = "sqlx-postgres"
|
||||||
))]
|
))]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
|
||||||
pub async fn find_by_id_with_result() {
|
pub async fn find_by_id_with_result() {
|
||||||
let ctx = TestContext::new("find_by_id_with_result").await;
|
let ctx = TestContext::new("find_by_id_with_result").await;
|
||||||
|
|
||||||
@ -99,7 +96,6 @@ pub async fn find_by_id_with_result() {
|
|||||||
feature = "sqlx-sqlite",
|
feature = "sqlx-sqlite",
|
||||||
feature = "sqlx-postgres"
|
feature = "sqlx-postgres"
|
||||||
))]
|
))]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
|
||||||
pub async fn find_all_with_no_result() {
|
pub async fn find_all_with_no_result() {
|
||||||
let ctx = TestContext::new("find_all_with_no_result").await;
|
let ctx = TestContext::new("find_all_with_no_result").await;
|
||||||
|
|
||||||
@ -115,7 +111,6 @@ pub async fn find_all_with_no_result() {
|
|||||||
feature = "sqlx-sqlite",
|
feature = "sqlx-sqlite",
|
||||||
feature = "sqlx-postgres"
|
feature = "sqlx-postgres"
|
||||||
))]
|
))]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
|
||||||
pub async fn find_all_with_result() {
|
pub async fn find_all_with_result() {
|
||||||
let ctx = TestContext::new("find_all_with_result").await;
|
let ctx = TestContext::new("find_all_with_result").await;
|
||||||
|
|
||||||
@ -150,7 +145,6 @@ pub async fn find_all_with_result() {
|
|||||||
feature = "sqlx-sqlite",
|
feature = "sqlx-sqlite",
|
||||||
feature = "sqlx-postgres"
|
feature = "sqlx-postgres"
|
||||||
))]
|
))]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
|
||||||
pub async fn find_all_filter_no_result() {
|
pub async fn find_all_filter_no_result() {
|
||||||
let ctx = TestContext::new("find_all_filter_no_result").await;
|
let ctx = TestContext::new("find_all_filter_no_result").await;
|
||||||
|
|
||||||
@ -189,7 +183,6 @@ pub async fn find_all_filter_no_result() {
|
|||||||
feature = "sqlx-sqlite",
|
feature = "sqlx-sqlite",
|
||||||
feature = "sqlx-postgres"
|
feature = "sqlx-postgres"
|
||||||
))]
|
))]
|
||||||
#[cfg(feature = "sqlx-mysql")]
|
|
||||||
pub async fn find_all_filter_with_results() {
|
pub async fn find_all_filter_with_results() {
|
||||||
let ctx = TestContext::new("find_all_filter_with_results").await;
|
let ctx = TestContext::new("find_all_filter_with_results").await;
|
||||||
|
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
// cargo test --test realtional_tests -- --nocapture
|
|
||||||
|
|
||||||
use chrono::offset::Utc;
|
use chrono::offset::Utc;
|
||||||
use rust_decimal::prelude::*;
|
use rust_decimal::prelude::*;
|
||||||
use rust_decimal_macros::dec;
|
use rust_decimal_macros::dec;
|
||||||
@ -8,6 +6,8 @@ use sea_orm::{entity::*, query::*, FromQueryResult};
|
|||||||
pub mod common;
|
pub mod common;
|
||||||
pub use common::{bakery_chain::*, setup::*, TestContext};
|
pub use common::{bakery_chain::*, setup::*, TestContext};
|
||||||
|
|
||||||
|
// Run the test locally:
|
||||||
|
// DATABASE_URL="mysql://root:@localhost" cargo test --features sqlx-mysql --test realtional_tests
|
||||||
#[async_std::test]
|
#[async_std::test]
|
||||||
#[cfg(any(
|
#[cfg(any(
|
||||||
feature = "sqlx-mysql",
|
feature = "sqlx-mysql",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user