From d7eaa14e5548014f855a0185a9277d6450d77a88 Mon Sep 17 00:00:00 2001 From: Philipp Hofer Date: Mon, 11 Nov 2024 15:26:33 +0100 Subject: [PATCH] fix tests --- src/model/event.rs | 13 +++++++++++-- src/model/notification.rs | 7 +++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/src/model/event.rs b/src/model/event.rs index a48d18e..c8af6ad 100644 --- a/src/model/event.rs +++ b/src/model/event.rs @@ -463,7 +463,13 @@ WHERE trip_details.id=? #[cfg(test)] mod test { - use crate::{model::tripdetails::TripDetails, testdb}; + use crate::{ + model::{ + tripdetails::TripDetails, + user::{EventUser, User}, + }, + testdb, + }; use super::Event; use chrono::Local; @@ -483,7 +489,10 @@ mod test { let trip_details = TripDetails::find_by_id(&pool, 1).await.unwrap(); - Event::create(&pool, "new-event".into(), 2, false, &trip_details).await; + let admin = EventUser::new(&pool, User::find_by_id(&pool, 1).await.unwrap()) + .await + .unwrap(); + Event::create(&pool, &admin, "new-event".into(), 2, false, &trip_details).await; let res = Event::get_for_day(&pool, Local::now().date_naive()).await; assert_eq!(res.len(), 2); diff --git a/src/model/notification.rs b/src/model/notification.rs index ae73ad3..4a3d274 100644 --- a/src/model/notification.rs +++ b/src/model/notification.rs @@ -221,7 +221,7 @@ mod test { notification::Notification, trip::Trip, tripdetails::{TripDetails, TripDetailsToAdd}, - user::{SteeringUser, User}, + user::{EventUser, SteeringUser, User}, usertrip::UserTrip, }, testdb, @@ -247,7 +247,10 @@ mod test { let trip_details = TripDetails::find_by_id(&pool, tripdetails_id) .await .unwrap(); - Event::create(&pool, "new-event".into(), 2, false, &trip_details).await; + let user = EventUser::new(&pool, User::find_by_id(&pool, 1).await.unwrap()) + .await + .unwrap(); + Event::create(&pool, &user, "new-event".into(), 2, false, &trip_details).await; let event = Event::find_by_trip_details(&pool, trip_details.id) .await .unwrap(); -- 2.45.2