even more tests!

This commit is contained in:
2023-04-26 12:21:30 +02:00
parent 1e92b166c7
commit a49de71a5d
7 changed files with 155 additions and 44 deletions

View File

@ -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,
}