From 6955c781c388ee70cff3046a4e7aa306f79569ac Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 15:57:42 -0400 Subject: [PATCH] Hopefully it works --- src/main.rs | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/src/main.rs b/src/main.rs index 852696d..c2aa6d4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -484,6 +484,7 @@ mod tests { method: axum::http::Method, has_body: bool, ) -> Result, axum::http::Error> { + let mut content_type = "application/json; charset=utf-8".to_string(); let body = if has_body { assert_eq!( true, @@ -491,17 +492,25 @@ mod tests { "Has request body and payload has data" ); // axum::body::Body::from(payload.unwrap().to_string()) - match payload.unwrap() { - ReqBody::Json(val) => axum::body::Body::from(val.to_string()), - ReqBody::Multipart((t, p)) => { - let mut form = MultipartForm::default(); - let _ = form.add_file(t, p); + match payload { + Some(p) => match p { + ReqBody::Json(val) => axum::body::Body::from(val.to_string()), + ReqBody::Multipart((t, p)) => { + let mut form = MultipartForm::default(); + let _ = form.add_file(t, p); - // Create request - let content_type = form.content_type(); - println!("Content: {content_type:?}"); - let body = MultipartBody::from(form); - axum::body::Body::from_stream(body) + // 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) + } + }, + None => { + eprintln!("This should not empty"); + axum::body::Body::empty() } } } else { @@ -512,7 +521,8 @@ mod tests { .uri(uri) .header( axum::http::header::CONTENT_TYPE, - "application/json; charset=utf-8", + content_type, + // "application/json; charset=utf-8", ) .header( axum::http::header::AUTHORIZATION, @@ -798,8 +808,10 @@ mod tests { let app = init::app(pool).await; // Send request + println!("Trying"); match request::song_queue_req(&app).await { Ok(response) => { + println!("response: {response:?}"); let resp = util::get_resp_data::< crate::callers::queue::song::response::song_queue::Response, >(response) @@ -808,6 +820,7 @@ mod tests { assert_eq!(false, resp.data[0].is_nil(), "Should not be empty"); } Err(err) => { + eprintln!("Failure!"); assert!(false, "Error: {:?}", err); } };