Skip to content

Commit

Permalink
Test create lineitem
Browse files Browse the repository at this point in the history
  • Loading branch information
samsamai committed Jul 8, 2021
1 parent 3b67ff8 commit 1ecc848
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/crud/create_lineitem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,24 @@ pub async fn test_create_lineitem(db: &DbConn) {

assert!(lineitem.is_some());
let lineitem_model = lineitem.unwrap();
// assert_eq!(lineitem_model.price, dec!(7.55));
assert_eq!(lineitem_model.price, dec!(7.55));

let cake: Option<cake::Model> = Cake::find_by_id(lineitem_model.cake_id)
.one(db)
.await
.expect("could not find cake");

let cake_model = cake.unwrap();
assert_eq!(cake_model.name, "Mud Cake");

let order: Option<order::Model> = Order::find_by_id(lineitem_model.order_id)
.one(db)
.await
.expect("could not find order");

let order_model = order.unwrap();
assert_eq!(
order_model.customer_id.unwrap(),
customer_insert_res.last_insert_id as i32
);
}

0 comments on commit 1ecc848

Please sign in to comment.