diff --git a/README.md b/README.md index c6fecdb..ad01892 100644 --- a/README.md +++ b/README.md @@ -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? diff --git a/src/model/tripdetails.rs b/src/model/tripdetails.rs index e26c88b..62d9721 100644 --- a/src/model/tripdetails.rs +++ b/src/model/tripdetails.rs @@ -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, + ); + } +}