| 8 | |
| 9 | #[sea_orm_macros::test] |
| 10 | pub async fn stream() -> Result<(), DbErr> { |
| 11 | use futures_util::StreamExt; |
| 12 | |
| 13 | let ctx = TestContext::new("stream").await; |
| 14 | create_tables(&ctx.db).await?; |
| 15 | |
| 16 | let bakery = bakery::ActiveModel { |
| 17 | name: Set("SeaSide Bakery".to_owned()), |
| 18 | profit_margin: Set(10.4), |
| 19 | ..Default::default() |
| 20 | } |
| 21 | .save(&ctx.db) |
| 22 | .await?; |
| 23 | |
| 24 | let result = Bakery::find_by_id(bakery.id.clone().unwrap()) |
| 25 | .stream(&ctx.db) |
| 26 | .await? |
| 27 | .next() |
| 28 | .await |
| 29 | .unwrap()?; |
| 30 | |
| 31 | assert_eq!(result.id, bakery.id.unwrap()); |
| 32 | |
| 33 | ctx.delete().await; |
| 34 | |
| 35 | Ok(()) |
| 36 | } |