fix ci + add test
This commit is contained in:
parent
31bf38f112
commit
dea0c65da3
@ -430,7 +430,7 @@ ORDER BY departure DESC
|
||||
for rower in &log.rowers {
|
||||
let user = User::find_by_id(db, *rower as i32).await.unwrap();
|
||||
if let Some(msg) = user.close_thousands_trip(db).await {
|
||||
ret.push_str(&format!("\n{msg}"));
|
||||
ret.push_str(&format!(" • {msg}"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -643,6 +643,7 @@ mod test {
|
||||
use crate::model::user::User;
|
||||
use crate::testdb;
|
||||
|
||||
use chrono::Duration;
|
||||
use sqlx::SqlitePool;
|
||||
|
||||
#[sqlx::test]
|
||||
@ -694,7 +695,7 @@ mod test {
|
||||
fn test_succ_create() {
|
||||
let pool = testdb!();
|
||||
|
||||
Logbook::create(
|
||||
let msg = Logbook::create(
|
||||
&pool,
|
||||
LogToAdd {
|
||||
boat_id: 3,
|
||||
@ -712,7 +713,62 @@ mod test {
|
||||
&User::find_by_id(&pool, 4).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap()
|
||||
.unwrap();
|
||||
assert_eq!(msg, String::from(""));
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
fn test_succ_create_with_thousands_msg() {
|
||||
let pool = testdb!();
|
||||
|
||||
let logbook = Logbook::find_by_id(&pool, 1).await.unwrap();
|
||||
let user = User::find_by_id(&pool, 2).await.unwrap();
|
||||
let current_date = chrono::Local::now().format("%Y-%m-%d").to_string();
|
||||
let start_date = chrono::Local::now() - Duration::days(3);
|
||||
let start_date = start_date.format("%Y-%m-%d").to_string();
|
||||
logbook
|
||||
.home(
|
||||
&pool,
|
||||
&user,
|
||||
super::LogToFinalize {
|
||||
destination: "new-destination".into(),
|
||||
distance_in_km: 995,
|
||||
comments: Some("Perfect water".into()),
|
||||
logtype: None,
|
||||
rowers: vec![2],
|
||||
shipmaster: Some(2),
|
||||
steering_person: Some(2),
|
||||
shipmaster_only_steering: false,
|
||||
departure: format!("{}T10:00", start_date),
|
||||
arrival: format!("{}T12:00", current_date),
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let msg = Logbook::create(
|
||||
&pool,
|
||||
LogToAdd {
|
||||
boat_id: 3,
|
||||
shipmaster: Some(2),
|
||||
steering_person: Some(2),
|
||||
shipmaster_only_steering: false,
|
||||
departure: "2128-05-20T12:00".into(),
|
||||
arrival: None,
|
||||
destination: None,
|
||||
distance_in_km: None,
|
||||
comments: None,
|
||||
logtype: None,
|
||||
rowers: vec![2],
|
||||
},
|
||||
&User::find_by_id(&pool, 1).await.unwrap(),
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
assert_eq!(
|
||||
msg,
|
||||
String::from(" • rower braucht nur mehr 5 km bis die 1000 km voll sind 🤑")
|
||||
);
|
||||
}
|
||||
|
||||
#[sqlx::test]
|
||||
|
@ -212,7 +212,7 @@ async fn create_logbook(
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(msg) => Flash::success(Redirect::to("/log"), format!("Ausfahrt erfolgreich hinzugefügt {msg}")),
|
||||
Ok(msg) => Flash::success(Redirect::to("/log"), format!("Ausfahrt erfolgreich hinzugefügt{msg}")),
|
||||
Err(LogbookCreateError::BoatAlreadyOnWater) => Flash::error(Redirect::to("/log"), "Boot schon am Wasser"),
|
||||
Err(LogbookCreateError::RowerAlreadyOnWater(rower)) => Flash::error(Redirect::to("/log"), format!("Ruderer {} schon am Wasser", rower.name)),
|
||||
Err(LogbookCreateError::BoatLocked) => Flash::error(Redirect::to("/log"),"Boot gesperrt"),
|
||||
|
Loading…
Reference in New Issue
Block a user