sea-orm/tests/stream_tests.rs
Billy Chan f3967fdaca
Upstream Changes - 1 (#2145)
* upstream changes

* universal `#[sea_orm_macros::test]`

* fix

* fix

* `ColumnTrait::into_returning_expr`

* fix

* fix

* Do not pub sqlx_common

---------

Co-authored-by: Chris Tsang <chris.2y3@outlook.com>
2024-03-10 18:14:46 +00:00

35 lines
774 B
Rust

pub mod common;
pub use common::{bakery_chain::*, setup::*, TestContext};
pub use sea_orm::entity::*;
pub use sea_orm::{ConnectionTrait, DbErr, QueryFilter};
#[sea_orm_macros::test]
pub async fn stream() -> Result<(), DbErr> {
use futures::StreamExt;
let ctx = TestContext::new("stream").await;
create_tables(&ctx.db).await?;
let bakery = bakery::ActiveModel {
name: Set("SeaSide Bakery".to_owned()),
profit_margin: Set(10.4),
..Default::default()
}
.save(&ctx.db)
.await?;
let result = Bakery::find_by_id(bakery.id.clone().unwrap())
.stream(&ctx.db)
.await?
.next()
.await
.unwrap()?;
assert_eq!(result.id, bakery.id.unwrap());
ctx.delete().await;
Ok(())
}