diff --git a/src/main.rs b/src/main.rs index 86936a5..0c449eb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,11 +25,6 @@ async fn main() { mod tests { use std::io::Write; - /* - use common_multipart_rfc7578::client::multipart::{ - Body as MultipartBody, Form as MultipartForm, - }; - */ use tower::ServiceExt; use crate::db; @@ -451,27 +446,8 @@ mod tests { Ok(response) => Ok(response), Err(err) => Err(axum::http::Error::from(err)), }, - Err(err) => { - Err(err) - // Err(std::convert::Infallible::from(err)) - // Err(err) - } + Err(err) => Err(err), } - - /* - let req = axum::http::Request::builder() - .method(axum::http::Method::GET) - .uri(uri) - .header(axum::http::header::CONTENT_TYPE, "application/json") - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::empty()) - .unwrap(); - - app.clone().oneshot(req).await - */ } pub enum ReqBody { @@ -493,7 +469,7 @@ mod tests { payload.is_some(), "Has request body and payload has data" ); - // axum::body::Body::from(payload.unwrap().to_string()) + match payload { Some(p) => match p { ReqBody::Json(val) => axum::body::Body::from(val.to_string()), @@ -501,12 +477,8 @@ mod tests { let mut form = MultipartForm::default(); let _ = form.add_file(t, p); - // Create request - // let content_type = form.content_type(); content_type = form.content_type(); - println!("Content: {content_type:?}"); let body = MultipartBody::from(form); - println!("Streaming"); axum::body::Body::from_stream(body) } }, @@ -521,11 +493,7 @@ mod tests { match axum::http::Request::builder() .method(method) .uri(uri) - .header( - axum::http::header::CONTENT_TYPE, - content_type, - // "application/json; charset=utf-8", - ) + .header(axum::http::header::CONTENT_TYPE, content_type) .header( axum::http::header::AUTHORIZATION, super::bearer_auth().await, @@ -1804,13 +1772,14 @@ mod tests { match app .clone() .oneshot( - axum::http::Request::builder() - .method(axum::http::Method::PATCH) - .uri(crate::callers::queue::endpoints::QUEUESONGDATAWIPE) - .header(axum::http::header::CONTENT_TYPE, "application/json") - .header(axum::http::header::AUTHORIZATION, bearer_auth().await) - .body(axum::body::Body::from(payload.to_string())) - .unwrap(), + request::run_post( + Some(request::ReqBody::Json(payload)), + crate::callers::queue::endpoints::QUEUESONGDATAWIPE, + axum::http::Method::PATCH, + true, + ) + .await + .unwrap(), ) .await {