fix tests and add new one
This commit is contained in:
parent
787b28cc23
commit
2fd5b65994
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user