()
| 380 | |
| 381 | #[sea_orm_macros::test] |
| 382 | pub async fn having() { |
| 383 | // customers with orders with total equal to $90 |
| 384 | let ctx = TestContext::new("test_having").await; |
| 385 | create_tables(&ctx.db).await.unwrap(); |
| 386 | |
| 387 | let bakery = bakery::ActiveModel { |
| 388 | name: Set("SeaSide Bakery".to_owned()), |
| 389 | profit_margin: Set(10.4), |
| 390 | ..Default::default() |
| 391 | } |
| 392 | .insert(&ctx.db) |
| 393 | .await |
| 394 | .expect("could not insert bakery"); |
| 395 | |
| 396 | let customer_kate = customer::ActiveModel { |
| 397 | name: Set("Kate".to_owned()), |
| 398 | ..Default::default() |
| 399 | } |
| 400 | .insert(&ctx.db) |
| 401 | .await |
| 402 | .expect("could not insert customer"); |
| 403 | |
| 404 | let kate_order_1 = order::ActiveModel { |
| 405 | bakery_id: Set(bakery.id), |
| 406 | customer_id: Set(customer_kate.id), |
| 407 | total: Set(rust_dec(100.00)), |
| 408 | placed_at: Set(Utc::now().naive_utc()), |
| 409 | |
| 410 | ..Default::default() |
| 411 | } |
| 412 | .insert(&ctx.db) |
| 413 | .await |
| 414 | .expect("could not insert order"); |
| 415 | |
| 416 | let _kate_order_2 = order::ActiveModel { |
| 417 | bakery_id: Set(bakery.id), |
| 418 | customer_id: Set(customer_kate.id), |
| 419 | total: Set(rust_dec(12.00)), |
| 420 | placed_at: Set(Utc::now().naive_utc()), |
| 421 | |
| 422 | ..Default::default() |
| 423 | } |
| 424 | .insert(&ctx.db) |
| 425 | .await |
| 426 | .expect("could not insert order"); |
| 427 | |
| 428 | let customer_bob = customer::ActiveModel { |
| 429 | name: Set("Bob".to_owned()), |
| 430 | ..Default::default() |
| 431 | } |
| 432 | .insert(&ctx.db) |
| 433 | .await |
| 434 | .expect("could not insert customer"); |
| 435 | |
| 436 | let _bob_order_1 = order::ActiveModel { |
| 437 | bakery_id: Set(bakery.id), |
| 438 | customer_id: Set(customer_bob.id), |
| 439 | total: Set(rust_dec(50.0)), |
nothing calls this directly
no test coverage detected