Separate schema tests
This commit is contained in:
parent
6104770b65
commit
391fb08260
@ -5,3 +5,11 @@ pub mod cakes_bakers;
|
||||
pub mod customer;
|
||||
pub mod lineitem;
|
||||
pub mod order;
|
||||
|
||||
pub use super::baker::Entity as Baker;
|
||||
pub use super::bakery::Entity as Bakery;
|
||||
pub use super::cake::Entity as Cake;
|
||||
pub use super::cakes_bakers::Entity as CakesBakers;
|
||||
pub use super::customer::Entity as Customer;
|
||||
pub use super::lineitem::Entity as Lineitem;
|
||||
pub use super::order::Entity as Order;
|
||||
|
@ -3,20 +3,26 @@ use sea_orm::DbConn;
|
||||
pub mod bakery_chain;
|
||||
mod setup;
|
||||
pub use bakery_chain::*;
|
||||
mod table_creation;
|
||||
mod crud;
|
||||
mod schema;
|
||||
|
||||
#[async_std::test]
|
||||
// cargo test --test bakery_chain_tests -- --nocapture
|
||||
async fn main() {
|
||||
let db: DbConn = setup::setup().await;
|
||||
setup_schema(&db).await;
|
||||
create_entities(&db).await;
|
||||
}
|
||||
|
||||
async fn setup_schema(db: &DbConn) {
|
||||
assert!(table_creation::create_bakery_table(db).await.is_ok());
|
||||
assert!(table_creation::create_baker_table(db).await.is_ok());
|
||||
assert!(table_creation::create_customer_table(db).await.is_ok());
|
||||
assert!(table_creation::create_order_table(db).await.is_ok());
|
||||
assert!(table_creation::create_lineitem_table(db).await.is_ok());
|
||||
assert!(table_creation::create_cakes_bakers_table(db).await.is_ok());
|
||||
assert!(schema::create_bakery_table(db).await.is_ok());
|
||||
assert!(schema::create_baker_table(db).await.is_ok());
|
||||
assert!(schema::create_customer_table(db).await.is_ok());
|
||||
assert!(schema::create_order_table(db).await.is_ok());
|
||||
assert!(schema::create_lineitem_table(db).await.is_ok());
|
||||
assert!(schema::create_cakes_bakers_table(db).await.is_ok());
|
||||
}
|
||||
|
||||
async fn create_entities(db: &DbConn) {
|
||||
assert!(crud::create_bakery(db).await.is_ok());
|
||||
}
|
||||
|
14
tests/crud/mod.rs
Normal file
14
tests/crud/mod.rs
Normal file
@ -0,0 +1,14 @@
|
||||
use sea_orm::{entity::*, DbConn, ExecErr, InsertResult};
|
||||
|
||||
pub use super::bakery_chain::*;
|
||||
|
||||
pub async fn create_bakery(db: &DbConn) -> Result<(), ExecErr> {
|
||||
let seaside_bakery = bakery::ActiveModel {
|
||||
name: Set("SeaSide Bakery".to_owned()),
|
||||
profit_margin: Set(10.4),
|
||||
..Default::default()
|
||||
};
|
||||
let res: InsertResult = Bakery::insert(seaside_bakery).exec(db).await?;
|
||||
|
||||
Ok(())
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user