diff --git a/src/model/trip.rs b/src/model/trip.rs index 5ca9b72..d378c88 100644 --- a/src/model/trip.rs +++ b/src/model/trip.rs @@ -320,12 +320,35 @@ mod test { let trip = Trip::find_by_id(&pool, 1).await.unwrap(); - assert!(Trip::update_own(&pool, &cox, &trip, 10, None).await.is_ok()); + assert!(Trip::update_own(&pool, &cox, &trip, 10, None, None) + .await + .is_ok()); let trip = Trip::find_by_id(&pool, 1).await.unwrap(); assert_eq!(trip.max_people, 10); } + #[sqlx::test] + fn test_succ_update_own_with_triptype() { + let pool = testdb!(); + + let cox: CoxUser = User::find_by_name(&pool, "cox".into()) + .await + .unwrap() + .try_into() + .unwrap(); + + let trip = Trip::find_by_id(&pool, 1).await.unwrap(); + + assert!(Trip::update_own(&pool, &cox, &trip, 10, None, Some(1)) + .await + .is_ok()); + + let trip = Trip::find_by_id(&pool, 1).await.unwrap(); + assert_eq!(trip.max_people, 10); + assert_eq!(trip.trip_type_id, Some(1)); + } + #[sqlx::test] fn test_fail_update_own_not_your_trip() { let pool = testdb!(); @@ -338,7 +361,7 @@ mod test { let trip = Trip::find_by_id(&pool, 1).await.unwrap(); - assert!(Trip::update_own(&pool, &cox, &trip, 10, None) + assert!(Trip::update_own(&pool, &cox, &trip, 10, None, None) .await .is_err()); assert_eq!(trip.max_people, 1);