Added code to test
Rust Build / Rustfmt (pull_request) Successful in 35s
Rust Build / Test Suite (pull_request) Failing after 1m0s

This commit is contained in:
2026-06-17 17:33:15 -04:00
parent a3443c0fa3
commit fe1ce848e1
+59 -1
View File
@@ -317,6 +317,46 @@ mod request {
Err(err) => Err(err),
}
}
pub mod scheduling {
use tower::ServiceExt;
pub async fn create_scheduled_message(
app: &axum::Router,
) -> Result<axum::response::Response, axum::http::Error> {
/*
let twenty_minutes_from_now = time::OffsetDateTime::now_utc().checked_add_signed(
time::Duration::<time>::minutes(20).unwrap(),
);
*/
/*
let now = time::OffsetDateTime::now_utc();
time::Duration::minutes(20).into().add(&now);
*/
let now = time::OffsetDateTime::now_utc();
let scheduled = now + std::time::Duration::from_secs(20 * 60);
let payload = serde_json::json!({
"scheduled": scheduled,
"status": textsender_models::message::scheduling::PENDING,
"user_id": super::super::super::TEST_USER_ID,
});
match super::super::run_post(
Some(&payload),
textsender_api::caller::endpoints::SCHEDULE_MESSAGE,
axum::http::Method::POST,
true,
)
.await
{
Ok(req) => match app.clone().oneshot(req).await {
Ok(response) => Ok(response),
Err(err) => Err(axum::http::Error::from(err)),
},
Err(err) => Err(err),
}
}
}
}
pub async fn run_post(
@@ -565,4 +605,22 @@ async fn test_get_message() {
}
#[tokio::test]
async fn test_schedule_message() {}
async fn test_schedule_message() {
let (tm_pool, db_name, pool) = db_mgr::get_database_ready().await;
let app = init::app(pool).await;
match request::message::scheduling::create_scheduled_message(&app).await {
Ok(response) => {
let resp = util::get_resp_data::<
textsender_api::caller::message::scheduling::response::ScheduleMessageResponse,
>(response)
.await;
assert_eq!(false, resp.data.is_empty(), "Should not be empty");
}
Err(err) => {
assert!(false, "Error: {err:?}");
}
}
let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
}