test: delete availability
This commit is contained in:
parent
33132697f2
commit
fac14ce9f1
@ -23,3 +23,44 @@ pub async fn delete(
|
||||
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use actix_http::StatusCode;
|
||||
use brass_db::models::{Availability, AvailabilityChangeset};
|
||||
use brass_macros::db_test;
|
||||
use chrono::NaiveDateTime;
|
||||
|
||||
use crate::utils::test_helper::{
|
||||
create_test_login_user, test_delete, DbTestContext, NaiveDateTimeExt, RequestConfig,
|
||||
};
|
||||
|
||||
#[db_test]
|
||||
async fn deletes_when_availability_is_from_user(context: &DbTestContext) {
|
||||
let app = context.app().await;
|
||||
let config = RequestConfig::new("/availability/delete/1");
|
||||
create_test_login_user(&context.db_pool, &config).await;
|
||||
|
||||
Availability::create(
|
||||
&context.db_pool,
|
||||
1,
|
||||
AvailabilityChangeset {
|
||||
time: (
|
||||
NaiveDateTime::from_ymd_and_hms(2025, 01, 01, 10, 0, 0).unwrap(),
|
||||
NaiveDateTime::from_ymd_and_hms(2025, 02, 01, 10, 0, 0).unwrap(),
|
||||
),
|
||||
comment: None,
|
||||
},
|
||||
)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let response = test_delete(&app, &config).await;
|
||||
assert_eq!(StatusCode::OK, response.status());
|
||||
}
|
||||
|
||||
// test deletes availability_from_another_But_area_manager_in_area
|
||||
// test doesnt_delete availability_from_another_But_area_manager_is_not_in_area
|
||||
// test deletest_availability_from_another_user_when_user_admin
|
||||
// test doesnt_delete availability_when_not_existing
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user