From 2fd5b659941a7e75db90d2d924330226fafbf3ad Mon Sep 17 00:00:00 2001 From: philipp Date: Wed, 3 May 2023 16:53:36 +0200 Subject: [PATCH] fix tests and add new one --- src/model/trip.rs | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) 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);