forked from Ruderverein-Donau-Linz/rowt
update tests to use current date
This commit is contained in:
parent
a3c7461c2b
commit
5b4238da92
@ -797,6 +797,8 @@ mod test {
|
|||||||
let logbook = Logbook::find_by_id(&pool, 1).await.unwrap();
|
let logbook = Logbook::find_by_id(&pool, 1).await.unwrap();
|
||||||
let user = User::find_by_id(&pool, 2).await.unwrap();
|
let user = User::find_by_id(&pool, 2).await.unwrap();
|
||||||
|
|
||||||
|
let current_date = chrono::Local::now().format("%Y-%m-%d").to_string();
|
||||||
|
|
||||||
logbook
|
logbook
|
||||||
.home(
|
.home(
|
||||||
&pool,
|
&pool,
|
||||||
@ -810,8 +812,8 @@ mod test {
|
|||||||
shipmaster: Some(2),
|
shipmaster: Some(2),
|
||||||
steering_person: Some(2),
|
steering_person: Some(2),
|
||||||
shipmaster_only_steering: false,
|
shipmaster_only_steering: false,
|
||||||
departure: "1990-01-01T10:00".into(),
|
departure: format!("{}T10:00", current_date),
|
||||||
arrival: "1990-01-01T12:00".into(),
|
arrival: format!("{}T12:00", current_date),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
@ -524,11 +524,12 @@ mod test {
|
|||||||
.header(ContentType::Form) // Set the content type to form
|
.header(ContentType::Form) // Set the content type to form
|
||||||
.body("name=admin&password=admin"); // Add the form data to the request body;
|
.body("name=admin&password=admin"); // Add the form data to the request body;
|
||||||
login.dispatch().await;
|
login.dispatch().await;
|
||||||
|
let current_date = chrono::Local::now().format("%Y-%m-%d").to_string();
|
||||||
|
|
||||||
let req = client
|
let req = client.post("/log").header(ContentType::Form).body(format!(
|
||||||
.post("/log")
|
"boat_id=1&shipmaster=4&departure={0}T10:00&steering_person=4&rowers[]=4",
|
||||||
.header(ContentType::Form)
|
current_date
|
||||||
.body("boat_id=1&shipmaster=4&departure=2199-12-31T10:00&steering_person=4&rowers[]=4");
|
));
|
||||||
let response = req.dispatch().await;
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
assert_eq!(response.status(), Status::SeeOther);
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
@ -556,10 +557,12 @@ mod test {
|
|||||||
let req = client.get("/log/kiosk/ekrv2019/Linz");
|
let req = client.get("/log/kiosk/ekrv2019/Linz");
|
||||||
let _ = req.dispatch().await;
|
let _ = req.dispatch().await;
|
||||||
|
|
||||||
|
let current_date = chrono::Local::now().format("%Y-%m-%d").to_string();
|
||||||
|
|
||||||
let req = client
|
let req = client
|
||||||
.post("/log/1")
|
.post("/log/1")
|
||||||
.header(ContentType::Form)
|
.header(ContentType::Form)
|
||||||
.body("destination=Ottensheim&distance_in_km=25&shipmaster=2&steering_person=2&departure=1990-01-01T10:00&arrival=1990-01-01T12:00&rowers[]=2");
|
.body(format!("destination=Ottensheim&distance_in_km=25&shipmaster=2&steering_person=2&departure={0}T10:00&arrival={0}T12:00&rowers[]=2", current_date));
|
||||||
let response = req.dispatch().await;
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
assert_eq!(response.status(), Status::SeeOther);
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
@ -666,9 +669,10 @@ mod test {
|
|||||||
.unwrap()
|
.unwrap()
|
||||||
.id;
|
.id;
|
||||||
let shipmaster_id = User::find_by_name(&db, "rower2".into()).await.unwrap().id;
|
let shipmaster_id = User::find_by_name(&db, "rower2".into()).await.unwrap().id;
|
||||||
|
let current_date = chrono::Local::now().format("%Y-%m-%d").to_string();
|
||||||
|
|
||||||
let req = client.post("/log").header(ContentType::Form).body(format!(
|
let req = client.post("/log").header(ContentType::Form).body(format!(
|
||||||
"boat_id={boat_id}&shipmaster={shipmaster_id}&departure=1199-12-31T10:00&steering_person={shipmaster_id}&rowers[]={shipmaster_id}"
|
"boat_id={boat_id}&shipmaster={shipmaster_id}&departure={0}T10:00&steering_person={shipmaster_id}&rowers[]={shipmaster_id}", current_date
|
||||||
));
|
));
|
||||||
let response = req.dispatch().await;
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
@ -697,7 +701,7 @@ mod test {
|
|||||||
let req = client
|
let req = client
|
||||||
.post(format!("/log/{log_id}"))
|
.post(format!("/log/{log_id}"))
|
||||||
.header(ContentType::Form)
|
.header(ContentType::Form)
|
||||||
.body(format!("destination=Ottensheim&distance_in_km=25&shipmaster={shipmaster_id}&steering_person={shipmaster_id}&departure=1990-01-01T10:00&arrival=1990-01-01T12:00&rowers[]={shipmaster_id}"));
|
.body(format!("destination=Ottensheim&distance_in_km=25&shipmaster={shipmaster_id}&steering_person={shipmaster_id}&departure={0}T10:00&arrival=1990-01-01T12:00&rowers[]={shipmaster_id}", current_date));
|
||||||
let response = req.dispatch().await;
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
assert_eq!(response.status(), Status::SeeOther);
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
@ -884,11 +888,12 @@ mod test {
|
|||||||
.header(ContentType::Form) // Set the content type to form
|
.header(ContentType::Form) // Set the content type to form
|
||||||
.body("name=rower2&password=rower"); // Add the form data to the request body;
|
.body("name=rower2&password=rower"); // Add the form data to the request body;
|
||||||
login.dispatch().await;
|
login.dispatch().await;
|
||||||
|
let current_date = chrono::Local::now().format("%Y-%m-%d").to_string();
|
||||||
|
|
||||||
let req = client
|
let req = client
|
||||||
.post("/log/1")
|
.post("/log/1")
|
||||||
.header(ContentType::Form)
|
.header(ContentType::Form)
|
||||||
.body("destination=Ottensheim&distance_in_km=25&shipmaster=1&steering_person=1&departure=1199-12-12T10:00&arrival=1199-12-12T12:00&rowers[]=1");
|
.body(format!("destination=Ottensheim&distance_in_km=25&shipmaster=1&steering_person=1&departure={0}T10:00&arrival={0}T12:00&rowers[]=1", current_date));
|
||||||
let response = req.dispatch().await;
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
assert_eq!(response.status(), Status::SeeOther);
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
@ -914,8 +919,10 @@ mod test {
|
|||||||
let boat_id = Boat::find_by_name(db, boat_name).await.unwrap().id;
|
let boat_id = Boat::find_by_name(db, boat_name).await.unwrap().id;
|
||||||
let shipmaster_id = User::find_by_name(db, &shipmaster_name).await.unwrap().id;
|
let shipmaster_id = User::find_by_name(db, &shipmaster_name).await.unwrap().id;
|
||||||
|
|
||||||
|
let current_date = chrono::Local::now().format("%Y-%m-%d").to_string();
|
||||||
|
|
||||||
let req = client.post("/log").header(ContentType::Form).body(format!(
|
let req = client.post("/log").header(ContentType::Form).body(format!(
|
||||||
"boat_id={boat_id}&shipmaster={shipmaster_id}&departure=1199-12-31T10:00&steering_person={shipmaster_id}&rowers[]={shipmaster_id}"
|
"boat_id={boat_id}&shipmaster={shipmaster_id}&departure={current_date}T10:00&steering_person={shipmaster_id}&rowers[]={shipmaster_id}"
|
||||||
));
|
));
|
||||||
let response = req.dispatch().await;
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
@ -937,7 +944,7 @@ mod test {
|
|||||||
let req = client
|
let req = client
|
||||||
.post(format!("/log/{log_id}"))
|
.post(format!("/log/{log_id}"))
|
||||||
.header(ContentType::Form)
|
.header(ContentType::Form)
|
||||||
.body(format!("destination=Ottensheim&distance_in_km=25&shipmaster={shipmaster_id}&steering_person={shipmaster_id}&departure=1199-12-31T10:00&arrival=1199-12-31T12:00&rowers[]={shipmaster_id}"));
|
.body(format!("destination=Ottensheim&distance_in_km=25&shipmaster={shipmaster_id}&steering_person={shipmaster_id}&departure={current_date}T10:00&arrival={current_date}T12:00&rowers[]={shipmaster_id}"));
|
||||||
let response = req.dispatch().await;
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
assert_eq!(response.status(), Status::SeeOther);
|
assert_eq!(response.status(), Status::SeeOther);
|
||||||
@ -964,8 +971,10 @@ mod test {
|
|||||||
let boat_id = Boat::find_by_name(db, boat_name).await.unwrap().id;
|
let boat_id = Boat::find_by_name(db, boat_name).await.unwrap().id;
|
||||||
let shipmaster_id = User::find_by_name(db, &shipmaster_name).await.unwrap().id;
|
let shipmaster_id = User::find_by_name(db, &shipmaster_name).await.unwrap().id;
|
||||||
|
|
||||||
|
let current_date = chrono::Local::now().format("%Y-%m-%d").to_string();
|
||||||
|
|
||||||
let req = client.post("/log").header(ContentType::Form).body(format!(
|
let req = client.post("/log").header(ContentType::Form).body(format!(
|
||||||
"boat_id={boat_id}&shipmaster={shipmaster_id}&departure=2199-12-31T10:00&steering_person={shipmaster_id}&rowers[]={shipmaster_id}"
|
"boat_id={boat_id}&shipmaster={shipmaster_id}&departure={current_date}T10:00&steering_person={shipmaster_id}&rowers[]={shipmaster_id}"
|
||||||
));
|
));
|
||||||
let response = req.dispatch().await;
|
let response = req.dispatch().await;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user