test: new assignment
This commit is contained in:
parent
10e6ba80a2
commit
507bb13a6e
@ -73,3 +73,84 @@ pub async fn post(
|
|||||||
|
|
||||||
Ok(template.to_response()?)
|
Ok(template.to_response()?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use brass_db::models::{
|
||||||
|
Availability, AvailabilityChangeset, Event, EventChangeset, Location, User,
|
||||||
|
};
|
||||||
|
use brass_macros::db_test;
|
||||||
|
use chrono::{NaiveDate, NaiveDateTime};
|
||||||
|
use fake::{Fake, Faker};
|
||||||
|
|
||||||
|
use crate::utils::test_helper::{DbTestContext, NaiveDateTimeExt};
|
||||||
|
|
||||||
|
#[db_test]
|
||||||
|
fn response_produces_updated_template(context: &DbTestContext) {
|
||||||
|
let app = context.app().await;
|
||||||
|
Location::create(&context.db_pool, &Faker.fake::<String>(), 1)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let start = NaiveDateTime::from_ymd_and_hms(2025, 01, 10, 10, 0, 0).unwrap();
|
||||||
|
let end = NaiveDateTime::from_ymd_and_hms(2025, 01, 10, 20, 0, 0).unwrap();
|
||||||
|
|
||||||
|
Event::create(
|
||||||
|
&context.db_pool,
|
||||||
|
EventChangeset::create_for_test(start, end),
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
User::create(&context.db_pool, Faker.fake()).await.unwrap();
|
||||||
|
|
||||||
|
// Availability::create(pool, 1, AvailabilityChangeset { time () })
|
||||||
|
|
||||||
|
assert!(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[db_test]
|
||||||
|
fn fails_when_availability_does_not_exist(context: &DbTestContext) {
|
||||||
|
assert!(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[db_test]
|
||||||
|
fn fails_when_event_does_not_exist(context: &DbTestContext) {
|
||||||
|
assert!(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[db_test]
|
||||||
|
fn fails_when_area_manager_is_different_area_from_event(context: &DbTestContext) {
|
||||||
|
assert!(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[db_test]
|
||||||
|
fn fails_when_availability_user_not_in_event_area(context: &DbTestContext) {
|
||||||
|
assert!(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[db_test]
|
||||||
|
fn fails_assignment_time_doesnt_fit_into_availability_time(context: &DbTestContext) {
|
||||||
|
assert!(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[db_test]
|
||||||
|
fn fails_when_end_time_lies_before_start_time(context: &DbTestContext) {
|
||||||
|
assert!(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[db_test]
|
||||||
|
fn fails_when_availability_time_already_assigned(context: &DbTestContext) {
|
||||||
|
assert!(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[db_test]
|
||||||
|
fn fails_when_availability_user_does_not_have_function(context: &DbTestContext) {
|
||||||
|
assert!(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[db_test]
|
||||||
|
fn fails_when_event_already_has_enough_assignments_for_function(context: &DbTestContext) {
|
||||||
|
assert!(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
mod test_context;
|
mod test_context;
|
||||||
mod test_requests;
|
mod test_requests;
|
||||||
|
use chrono::{NaiveDate, NaiveDateTime};
|
||||||
pub use test_context::{setup, teardown, DbTestContext};
|
pub use test_context::{setup, teardown, DbTestContext};
|
||||||
pub use test_requests::RequestConfig;
|
pub use test_requests::RequestConfig;
|
||||||
pub use test_requests::{read_body, test_delete, test_get, test_post, test_put};
|
pub use test_requests::{read_body, test_delete, test_get, test_post, test_put};
|
||||||
@ -27,3 +28,27 @@ macro_rules! assert_mail_snapshot {
|
|||||||
|
|
||||||
pub(crate) use assert_mail_snapshot;
|
pub(crate) use assert_mail_snapshot;
|
||||||
pub(crate) use assert_snapshot;
|
pub(crate) use assert_snapshot;
|
||||||
|
|
||||||
|
pub trait NaiveDateTimeExt {
|
||||||
|
fn from_ymd_and_hms(
|
||||||
|
year: i32,
|
||||||
|
month: u32,
|
||||||
|
day: u32,
|
||||||
|
hour: u32,
|
||||||
|
minute: u32,
|
||||||
|
second: u32,
|
||||||
|
) -> Option<NaiveDateTime>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NaiveDateTimeExt for NaiveDateTime {
|
||||||
|
fn from_ymd_and_hms(
|
||||||
|
year: i32,
|
||||||
|
month: u32,
|
||||||
|
day: u32,
|
||||||
|
hour: u32,
|
||||||
|
minute: u32,
|
||||||
|
second: u32,
|
||||||
|
) -> Option<NaiveDateTime> {
|
||||||
|
NaiveDate::from_ymd_opt(year, month, day)?.and_hms_opt(hour, minute, second)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user