add tests for trip_details

This commit is contained in:
philipp 2023-04-26 11:31:02 +02:00
parent 7a2639bbb1
commit 1e92b166c7
2 changed files with 32 additions and 0 deletions

View File

@ -19,3 +19,12 @@
´cd frontend´
´npm install´
´npm run (watch/build)´
# Backend tests
- [x] model/user.rs
- [x] model/tripdetails.rs
- [ ] model/planned_event.rs
- [ ] model/trip.rs
- [ ] model/usertrip.rs
- [ ] Rest?

View File

@ -11,6 +11,7 @@ pub struct TripDetails {
}
impl TripDetails {
/// Creates a new entry in `trip_details` and returns its id.
pub async fn create(
db: &SqlitePool,
planned_starting_time: String,
@ -31,3 +32,25 @@ impl TripDetails {
query.last_insert_rowid()
}
}
#[cfg(test)]
mod test {
use crate::testdb;
use super::TripDetails;
use sqlx::SqlitePool;
#[sqlx::test]
fn test() {
let pool = testdb!();
assert_eq!(
TripDetails::create(&pool, "10:00".into(), 2, "1970-01-01".into(), None).await,
1,
);
assert_eq!(
TripDetails::create(&pool, "10:00".into(), 2, "1970-01-01".into(), None).await,
2,
);
}
}