even more tests!
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
use super::planned_event::PlannedEvent;
|
||||
use super::tripdetails::TripDetails;
|
||||
|
||||
pub struct UserTrip {}
|
||||
|
||||
@ -10,7 +10,11 @@ impl UserTrip {
|
||||
user_id: i64,
|
||||
trip_details_id: i64,
|
||||
) -> Result<(), UserTripError> {
|
||||
if PlannedEvent::is_full(db, trip_details_id).await {
|
||||
let trip_details = TripDetails::find_by_id(&db, trip_details_id)
|
||||
.await
|
||||
.ok_or(UserTripError::TripDetailsNotFound)?;
|
||||
|
||||
if trip_details.is_full(db).await {
|
||||
return Err(UserTripError::EventAlreadyFull);
|
||||
}
|
||||
|
||||
@ -78,4 +82,5 @@ pub enum UserTripError {
|
||||
AlreadyRegistered,
|
||||
AlreadyRegisteredAsCox,
|
||||
EventAlreadyFull,
|
||||
TripDetailsNotFound,
|
||||
}
|
||||
|
Reference in New Issue
Block a user