forked from Ruderverein-Donau-Linz/rowt
add tests for trip_details
This commit is contained in:
parent
7a2639bbb1
commit
1e92b166c7
@ -19,3 +19,12 @@
|
|||||||
´cd frontend´
|
´cd frontend´
|
||||||
´npm install´
|
´npm install´
|
||||||
´npm run (watch/build)´
|
´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?
|
||||||
|
@ -11,6 +11,7 @@ pub struct TripDetails {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl TripDetails {
|
impl TripDetails {
|
||||||
|
/// Creates a new entry in `trip_details` and returns its id.
|
||||||
pub async fn create(
|
pub async fn create(
|
||||||
db: &SqlitePool,
|
db: &SqlitePool,
|
||||||
planned_starting_time: String,
|
planned_starting_time: String,
|
||||||
@ -31,3 +32,25 @@ impl TripDetails {
|
|||||||
query.last_insert_rowid()
|
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,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user