From 0f1c3bb70fb2dfba8b6627241b0636824a48ce52 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 11:07:09 -0400 Subject: [PATCH 01/14] Test refactor --- src/main.rs | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index af7f0a4..5acb0db 100644 --- a/src/main.rs +++ b/src/main.rs @@ -437,13 +437,30 @@ mod tests { pub async fn get_queued_coverart( app: &axum::Router, coverart_queue_id: &uuid::Uuid, - ) -> Result { + ) -> Result { let uri = format!( "{}?id={}", crate::callers::queue::endpoints::QUEUECOVERART, coverart_queue_id ); + match run_post(None, &uri, axum::http::Method::GET, false).await { + Ok(request) => match app.clone().oneshot(request).await { + Ok(response) => { + Ok(response) + } + Err(err) => { + Err(axum::http::Error::from(err)) + } + } + Err(err) => { + Err(err) + // Err(std::convert::Infallible::from(err)) + // Err(err) + } + } + + /* let req = axum::http::Request::builder() .method(axum::http::Method::GET) .uri(uri) @@ -456,6 +473,52 @@ mod tests { .unwrap(); app.clone().oneshot(req).await + */ + } + + pub enum ReqBody { + Json(serde_json::Value), + + } + + pub async fn run_post( + // payload: Option<&serde_json::Value>, + payload: Option, + uri: &str, + method: axum::http::Method, + has_body: bool, + ) -> Result, axum::http::Error> { + let body = if has_body { + assert_eq!( + true, + payload.is_some(), + "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()) + } + } + } else { + axum::body::Body::empty() + }; + match axum::http::Request::builder() + .method(method) + .uri(uri) + .header( + axum::http::header::CONTENT_TYPE, + "application/json; charset=utf-8", + ) + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) + .body(body) + { + Ok(t) => Ok(t), + Err(err) => Err(err), + } } } -- 2.47.3 From 5a4ba40064b3dd38b80aef7c59639647649a822e Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 11:07:25 -0400 Subject: [PATCH 02/14] bump: labyrinth --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a9d6d28..177c56e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1937,8 +1937,8 @@ checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37" [[package]] name = "labyrinth" -version = "0.0.2" -source = "git+ssh://git@git.kundeng.us/phoenix/labyrinth.git?tag=v0.0.2-1-84f98521c8-928#84f98521c8c98693e422db48eb0aa7c124c2586b" +version = "0.0.3" +source = "git+ssh://git@git.kundeng.us/phoenix/labyrinth.git?tag=v0.0.3-3-f99a77ece0-928#f99a77ece0d066ee96867936eb280db367354e0a" dependencies = [ "aws-config", "aws-sdk-s3", diff --git a/Cargo.toml b/Cargo.toml index 3120101..c1c3299 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] } simeta = { git = "ssh://git@git.kundeng.us/phoenix/simeta.git", tag = "v0.6.1-main-b690995806-680" } simodels = { git = "ssh://git@git.kundeng.us/phoenix/simodels.git", tag = "v0.11.3-main-fe9d101bd0-111" } sienvy = { git = "ssh://git@git.kundeng.us/phoenix/sienvy.git", tag = "v0.8.0-main-d06c8fdf49-006" } -labyrinth = { git = "ssh://git@git.kundeng.us/phoenix/labyrinth.git", tag = "v0.0.2-1-84f98521c8-928" } +labyrinth = { git = "ssh://git@git.kundeng.us/phoenix/labyrinth.git", tag = "v0.0.3-3-f99a77ece0-928" } [dev-dependencies] common-multipart-rfc7578 = { version = "0.7.0" } -- 2.47.3 From f235073641207fba9453c193ff073ab0acd81598 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 11:07:44 -0400 Subject: [PATCH 03/14] Adding s3 code --- src/callers/queue/song.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/callers/queue/song.rs b/src/callers/queue/song.rs index 8746da0..b0744c1 100644 --- a/src/callers/queue/song.rs +++ b/src/callers/queue/song.rs @@ -212,6 +212,31 @@ pub mod endpoint { match lr.upload(&file_path, &data).await { Ok(res) => { println!("Result: {res:?}"); + + println!("Downloading file"); + match lr.download(&file_path).await { + Ok(res) => { + if res.is_empty() { + println!("This should not be empty"); + } else { + println!("Size: {:?}", res.len()); + println!("Going to delete file"); + + match lr.delete(&file_path).await { + Ok(res) => { + println!("Result: {res:?}"); + println!("Deleted"); + } + Err(err) => { + eprintln!("Error: {err:?}"); + } + } + } + } + Err(err) => { + eprintln!("Error: {err:?}"); + } + } } Err(err) => match err { labyrinth::Error::Info(err_str) => { -- 2.47.3 From 8e4074485931cca55639b8f9f993c4dc2c635c5e Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 11:21:41 -0400 Subject: [PATCH 04/14] Fix error --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 5acb0db..0497a11 100644 --- a/src/main.rs +++ b/src/main.rs @@ -582,7 +582,7 @@ mod tests { pub async fn queue_coverart_flow( app: &axum::Router, song_queue_id: &uuid::Uuid, - ) -> Result { + ) -> Result { match super::request::upload_coverart_queue_req(&app).await { Ok(response) => { let resp = super::util::get_resp_data::< -- 2.47.3 From 3cd5817a1463a80d0f5c3a198519f24553f65928 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 11:54:09 -0400 Subject: [PATCH 05/14] Refactor tests --- src/main.rs | 359 +++++++++++++++++++++++++++------------------------- 1 file changed, 189 insertions(+), 170 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0497a11..852696d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -193,251 +193,251 @@ mod tests { pub async fn song_queue_req( app: &axum::Router, - ) -> Result { + ) -> Result { // Create multipart form - let mut form = MultipartForm::default(); - let _ = form.add_file("flac", "tests/I/track01.flac"); - - // Create request - let content_type = form.content_type(); - let body = MultipartBody::from(form); - let req = axum::http::Request::builder() - .method(axum::http::Method::POST) - .uri(crate::callers::queue::endpoints::QUEUESONG) - .header(axum::http::header::CONTENT_TYPE, content_type) - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::from_stream(body)) - .unwrap(); - app.clone().oneshot(req).await + match run_post( + Some(ReqBody::Multipart(( + "flac".to_string(), + "tests/I/track01.flac".to_string(), + ))), + crate::callers::queue::endpoints::QUEUESONG, + axum::http::Method::POST, + true, + ) + .await + { + Ok(request) => match app.clone().oneshot(request).await { + Ok(response) => Ok(response), + Err(err) => Err(axum::http::Error::from(err)), + }, + Err(err) => Err(err), + } } pub async fn song_queue_link_req( app: &axum::Router, song_queue_id: &uuid::Uuid, user_id: &uuid::Uuid, - ) -> Result { + ) -> Result { let payload = super::payload_data::link_user_to_queued_song(song_queue_id, user_id).await; - let req = axum::http::Request::builder() - .method(axum::http::Method::PATCH) - .uri(crate::callers::queue::endpoints::QUEUESONGLINKUSERID) - .header(axum::http::header::CONTENT_TYPE, "application/json") - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::from(payload.to_string())) - .unwrap(); - - app.clone().oneshot(req).await + match run_post( + Some(ReqBody::Json(payload)), + crate::callers::queue::endpoints::QUEUESONGLINKUSERID, + axum::http::Method::PATCH, + true, + ) + .await + { + Ok(request) => match app.clone().oneshot(request).await { + Ok(response) => Ok(response), + Err(err) => Err(axum::http::Error::from(err)), + }, + Err(err) => Err(err), + } } pub async fn fetch_queue_req( app: &axum::Router, - ) -> Result { - let fetch_req = axum::http::Request::builder() - .method(axum::http::Method::GET) - .uri(crate::callers::queue::endpoints::NEXTQUEUESONG) - .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(fetch_req).await + ) -> Result { + match run_post( + None, + crate::callers::queue::endpoints::NEXTQUEUESONG, + axum::http::Method::GET, + false, + ) + .await + { + Ok(request) => match app.clone().oneshot(request).await { + Ok(response) => Ok(response), + Err(err) => Err(axum::http::Error::from(err)), + }, + Err(err) => Err(err), + } } pub async fn fetch_metadata_queue_req( app: &axum::Router, id: &uuid::Uuid, - ) -> Result { + ) -> Result { let uri = format!( "{}?id={}", crate::callers::queue::endpoints::QUEUEMETADATA, id ); - 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 + match run_post(None, &uri, axum::http::Method::GET, false).await { + Ok(request) => match app.clone().oneshot(request).await { + Ok(response) => Ok(response), + Err(err) => Err(axum::http::Error::from(err)), + }, + Err(err) => Err(err), + } } pub async fn fetch_queue_data_req( app: &axum::Router, id: &uuid::Uuid, - ) -> Result { + ) -> Result { let raw_uri = String::from(crate::callers::queue::endpoints::QUEUESONGDATA); let end_index = raw_uri.len() - 4; let mut uri: String = (&raw_uri[..end_index]).to_string(); uri += &id.to_string(); - let req = axum::http::Request::builder() - .method(axum::http::Method::GET) - .uri(uri) - .header( - axum::http::header::CONTENT_TYPE, - simeta::detection::song::constants::mime::FLAC, - ) - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::empty()) - .unwrap(); - app.clone().oneshot(req).await + match run_post(None, &uri, axum::http::Method::GET, false).await { + Ok(request) => match app.clone().oneshot(request).await { + Ok(response) => Ok(response), + Err(err) => Err(axum::http::Error::from(err)), + }, + Err(err) => Err(err), + } } pub async fn upload_coverart_queue_req( app: &axum::Router, - ) -> Result { - let mut form = MultipartForm::default(); - let _ = form.add_file( - simeta::detection::coverart::constants::JPEG_TYPE, - "tests/I/Coverart-1.jpg", - ); - - // Create request - let content_type = form.content_type(); - let body = MultipartBody::from(form); - - let req = axum::http::Request::builder() - .method(axum::http::Method::POST) - .uri(crate::callers::queue::endpoints::QUEUECOVERART) - .header(axum::http::header::CONTENT_TYPE, content_type) - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::from_stream(body)) - .unwrap(); - - app.clone().oneshot(req).await + ) -> Result { + match run_post( + Some(ReqBody::Multipart(( + simeta::detection::coverart::constants::JPEG_TYPE.to_string(), + "tests/I/Coverart-1.jpg".to_string(), + ))), + crate::callers::queue::endpoints::QUEUECOVERART, + axum::http::Method::POST, + true, + ) + .await + { + Ok(request) => match app.clone().oneshot(request).await { + Ok(response) => Ok(response), + Err(err) => Err(axum::http::Error::from(err)), + }, + Err(err) => Err(err), + } } pub async fn queue_metadata_req( app: &axum::Router, song_queue_id: &uuid::Uuid, - ) -> Result { + ) -> Result { let payload = super::payload_data::queue_metadata(&song_queue_id).await; - let req = axum::http::Request::builder() - .method(axum::http::Method::POST) - .uri(crate::callers::queue::endpoints::QUEUEMETADATA) - .header(axum::http::header::CONTENT_TYPE, "application/json") - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::from(payload.to_string())) - .unwrap(); - - app.clone().oneshot(req).await + match run_post( + Some(ReqBody::Json(payload)), + crate::callers::queue::endpoints::QUEUEMETADATA, + axum::http::Method::POST, + true, + ) + .await + { + Ok(request) => match app.clone().oneshot(request).await { + Ok(response) => Ok(response), + Err(err) => Err(axum::http::Error::from(err)), + }, + Err(err) => Err(err), + } } pub async fn coverart_queue_song_queue_link_req( app: &axum::Router, coverart_id: &uuid::Uuid, song_queue_id: &uuid::Uuid, - ) -> Result { + ) -> Result { let payload = super::payload_data::link_queued_coverart_to_queued_song( song_queue_id, coverart_id, ) .await; - let req = axum::http::Request::builder() - .method(axum::http::Method::PATCH) - .uri(crate::callers::queue::endpoints::QUEUECOVERARTLINK) - .header(axum::http::header::CONTENT_TYPE, "application/json") - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::from(payload.to_string())) - .unwrap(); - app.clone().oneshot(req).await + match run_post( + Some(ReqBody::Json(payload)), + crate::callers::queue::endpoints::QUEUECOVERARTLINK, + axum::http::Method::PATCH, + true, + ) + .await + { + Ok(request) => match app.clone().oneshot(request).await { + Ok(response) => Ok(response), + Err(err) => Err(axum::http::Error::from(err)), + }, + Err(err) => Err(err), + } } pub async fn create_coverart_req( app: &axum::Router, song_id: &uuid::Uuid, coverart_id: &uuid::Uuid, - ) -> Result { + ) -> Result { let payload = super::payload_data::create_coverart(song_id, coverart_id).await; - let req = axum::http::Request::builder() - .method(axum::http::Method::POST) - .uri(crate::callers::endpoints::CREATECOVERART) - .header(axum::http::header::CONTENT_TYPE, "application/json") - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::from(payload.to_string())) - .unwrap(); - app.clone().oneshot(req).await + match run_post( + Some(ReqBody::Json(payload)), + crate::callers::endpoints::CREATECOVERART, + axum::http::Method::POST, + true, + ) + .await + { + Ok(request) => match app.clone().oneshot(request).await { + Ok(response) => Ok(response), + Err(err) => Err(axum::http::Error::from(err)), + }, + Err(err) => Err(err), + } } pub async fn create_song_req( app: &axum::Router, song_queue_id: &uuid::Uuid, user_id: &uuid::Uuid, - ) -> Result { + ) -> Result { let payload = super::payload_data::create_song(song_queue_id, user_id).await; - let req = axum::http::Request::builder() - .method(axum::http::Method::POST) - .uri(crate::callers::endpoints::CREATESONG) - .header(axum::http::header::CONTENT_TYPE, "application/json") - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::from(payload.to_string())) - .unwrap(); - - app.clone().oneshot(req).await + match run_post( + Some(ReqBody::Json(payload)), + crate::callers::endpoints::CREATESONG, + axum::http::Method::POST, + true, + ) + .await + { + Ok(request) => match app.clone().oneshot(request).await { + Ok(response) => Ok(response), + Err(err) => Err(axum::http::Error::from(err)), + }, + Err(err) => Err(err), + } } pub async fn update_song_queue_status_req( app: &axum::Router, song_queue_id: &uuid::Uuid, - ) -> Result { + ) -> Result { let payload = super::payload_data::update_song_queue_status_to_ready(song_queue_id).await; - let req = axum::http::Request::builder() - .method(axum::http::Method::PATCH) - .uri(crate::callers::queue::endpoints::QUEUESONG) - .header(axum::http::header::CONTENT_TYPE, "application/json") - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::from(payload.to_string())) - .unwrap(); - - app.clone().oneshot(req).await + match run_post( + Some(ReqBody::Json(payload)), + crate::callers::queue::endpoints::QUEUESONG, + axum::http::Method::PATCH, + true, + ) + .await + { + Ok(request) => match app.clone().oneshot(request).await { + Ok(response) => Ok(response), + Err(err) => Err(axum::http::Error::from(err)), + }, + Err(err) => Err(err), + } } pub async fn get_queued_coverart( app: &axum::Router, coverart_queue_id: &uuid::Uuid, - ) -> Result { + ) -> Result { let uri = format!( "{}?id={}", crate::callers::queue::endpoints::QUEUECOVERART, @@ -446,13 +446,9 @@ mod tests { match run_post(None, &uri, axum::http::Method::GET, false).await { Ok(request) => match app.clone().oneshot(request).await { - Ok(response) => { - Ok(response) - } - Err(err) => { - Err(axum::http::Error::from(err)) - } - } + Ok(response) => Ok(response), + Err(err) => Err(axum::http::Error::from(err)), + }, Err(err) => { Err(err) // Err(std::convert::Infallible::from(err)) @@ -478,7 +474,7 @@ mod tests { pub enum ReqBody { Json(serde_json::Value), - + Multipart((String, String)), } pub async fn run_post( @@ -496,8 +492,16 @@ mod tests { ); // axum::body::Body::from(payload.unwrap().to_string()) match payload.unwrap() { - ReqBody::Json(val) => { - axum::body::Body::from(val.to_string()) + 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) } } } else { @@ -526,7 +530,7 @@ mod tests { // Flow for queueing song pub async fn queue_song_flow( app: &axum::Router, - ) -> Result<(axum::response::Response, uuid::Uuid), std::convert::Infallible> { + ) -> Result<(axum::response::Response, uuid::Uuid), axum::http::Error> { match super::request::song_queue_req(&app).await { Ok(response) => { let resp = super::util::get_resp_data::< @@ -569,6 +573,10 @@ mod tests { Err(err) => Err(err), } } + Err(err) => { + assert!(false, "Error: {:?}", err); + Err(err) + } } } Err(err) => Err(err), @@ -618,15 +626,23 @@ mod tests { Err(err) => Err(err), } } + Err(err) => { + assert!(false, "Error: {:?}", err); + Err(err) + } } } + Err(err) => { + assert!(false, "Error: {:?}", err); + Err(err) + } } } // Returns coverart response and song_queue_id pub async fn queue_song_and_coverart_flow( app: &axum::Router, - ) -> Result<(axum::response::Response, uuid::Uuid), std::convert::Infallible> { + ) -> Result<(axum::response::Response, uuid::Uuid), axum::http::Error> { match queue_song_flow(&app).await { Ok((song_response, user_id)) => { let resp = super::util::get_resp_data::< @@ -1711,6 +1727,9 @@ mod tests { } } } + Err(err) => { + assert!(false, "Error: {:?}", err); + } } } Err(err) => { -- 2.47.3 From 6955c781c388ee70cff3046a4e7aa306f79569ac Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 15:57:42 -0400 Subject: [PATCH 06/14] 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); } }; -- 2.47.3 From 7478f353ce26e4632e8d36f7d48332bd61cbedfe Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 16:10:05 -0400 Subject: [PATCH 07/14] Refactor --- src/main.rs | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index c2aa6d4..cb4fd1f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2475,16 +2475,14 @@ mod tests { match app .clone() .oneshot( - axum::http::Request::builder() - .method(axum::http::Method::GET) - .uri(crate::callers::endpoints::GETALLSONGS) - .header(axum::http::header::CONTENT_TYPE, "application/json") - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::empty()) - .unwrap(), + super::request::run_post( + None, + crate::callers::endpoints::GETALLSONGS, + axum::http::Method::GET, + false, + ) + .await + .unwrap(), ) .await { -- 2.47.3 From 919803a2cceac9b231bb9a159e1a1810be86f506 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 16:23:32 -0400 Subject: [PATCH 08/14] Saving test --- src/main.rs | 94 +++++------------------------------------------------ 1 file changed, 8 insertions(+), 86 deletions(-) diff --git a/src/main.rs b/src/main.rs index cb4fd1f..ae8a1df 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1023,13 +1023,6 @@ mod tests { } let songpath = song.song_path().unwrap(); - let mut form = MultipartForm::default(); - let _ = form.add_file("flac", &songpath); - - // Create request - let content_type = form.content_type(); - let body = MultipartBody::from(form); - let raw_uri = String::from(crate::callers::queue::endpoints::QUEUESONGUPDATE); let end_index = raw_uri.len() - 5; @@ -1043,16 +1036,7 @@ mod tests { match app .clone() .oneshot( - axum::http::Request::builder() - .method(axum::http::Method::PATCH) - .uri(uri) - .header(axum::http::header::CONTENT_TYPE, content_type) - .header( - axum::http::header::AUTHORIZATION, - bearer_auth().await, - ) - .body(axum::body::Body::from_stream(body)) - .unwrap(), + request::run_post(Some(request::ReqBody::Multipart(("flac".to_string(), songpath))), &uri, axum::http::Method::PATCH, true).await.unwrap() ) .await { @@ -1928,19 +1912,7 @@ mod tests { match app .clone() .oneshot( - axum::http::Request::builder() - .method(axum::http::Method::PATCH) - .uri(crate::callers::queue::endpoints::QUEUECOVERARTDATAWIPE) - .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::QUEUECOVERARTDATAWIPE, axum::http::Method::PATCH, true).await.unwrap() ) .await { @@ -2008,16 +1980,7 @@ mod tests { match app .clone() .oneshot( - 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(), + super::request::run_post(None, &uri, axum::http::Method::GET, false).await.unwrap() ) .await { @@ -2065,16 +2028,7 @@ mod tests { match app .clone() .oneshot( - 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(), + super::request::run_post(None, &uri, axum::http::Method::GET, false).await.unwrap() ) .await { @@ -2154,15 +2108,7 @@ mod tests { match app .clone() .oneshot( - axum::http::Request::builder() - .method(axum::http::Method::GET) - .uri(&uri) - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::empty()) - .unwrap(), + super::request::run_post(None, &uri, axum::http::Method::GET, false).await.unwrap() ) .await { @@ -2214,15 +2160,7 @@ mod tests { match app .clone() .oneshot( - axum::http::Request::builder() - .method(axum::http::Method::GET) - .uri(&uri) - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::empty()) - .unwrap(), + super::request::run_post(None, &uri, axum::http::Method::GET, false).await.unwrap() ) .await { @@ -2276,15 +2214,7 @@ mod tests { match app .clone() .oneshot( - axum::http::Request::builder() - .method(axum::http::Method::GET) - .uri(&uri) - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::empty()) - .unwrap(), + super::request::run_post(None, &uri, axum::http::Method::GET, false).await.unwrap() ) .await { @@ -2403,15 +2333,7 @@ mod tests { match app .clone() .oneshot( - axum::http::Request::builder() - .method(axum::http::Method::DELETE) - .uri(&uri) - .header( - axum::http::header::AUTHORIZATION, - super::bearer_auth().await, - ) - .body(axum::body::Body::empty()) - .unwrap(), + super::request::run_post(None, &uri, axum::http::Method::DELETE, false).await.unwrap() ) .await { -- 2.47.3 From 9a6985873cdf882dca996b7f2e9a3846fb693155 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 16:25:37 -0400 Subject: [PATCH 09/14] What?? --- src/main.rs | 63 ++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/src/main.rs b/src/main.rs index ae8a1df..52e801a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1036,7 +1036,17 @@ mod tests { match app .clone() .oneshot( - request::run_post(Some(request::ReqBody::Multipart(("flac".to_string(), songpath))), &uri, axum::http::Method::PATCH, true).await.unwrap() + request::run_post( + Some(request::ReqBody::Multipart(( + "flac".to_string(), + songpath, + ))), + &uri, + axum::http::Method::PATCH, + true, + ) + .await + .unwrap(), ) .await { @@ -1517,16 +1527,14 @@ mod tests { match app .clone() .oneshot( - axum::http::Request::builder() - .method(axum::http::Method::GET) - .uri(uri) - .header(axum::http::header::CONTENT_TYPE, "image/jpeg") - .header( - axum::http::header::AUTHORIZATION, - bearer_auth().await, - ) - .body(axum::body::Body::empty()) - .unwrap(), + request::run_post( + None, + &uri, + axum::http::Method::GET, + false, + ) + .await + .unwrap(), ) .await { @@ -1912,7 +1920,14 @@ mod tests { match app .clone() .oneshot( - request::run_post(Some(request::ReqBody::Json(payload)), crate::callers::queue::endpoints::QUEUECOVERARTDATAWIPE, axum::http::Method::PATCH, true).await.unwrap() + request::run_post( + Some(request::ReqBody::Json(payload)), + crate::callers::queue::endpoints::QUEUECOVERARTDATAWIPE, + axum::http::Method::PATCH, + true, + ) + .await + .unwrap(), ) .await { @@ -1980,7 +1995,9 @@ mod tests { match app .clone() .oneshot( - super::request::run_post(None, &uri, axum::http::Method::GET, false).await.unwrap() + super::request::run_post(None, &uri, axum::http::Method::GET, false) + .await + .unwrap(), ) .await { @@ -2028,7 +2045,9 @@ mod tests { match app .clone() .oneshot( - super::request::run_post(None, &uri, axum::http::Method::GET, false).await.unwrap() + super::request::run_post(None, &uri, axum::http::Method::GET, false) + .await + .unwrap(), ) .await { @@ -2108,7 +2127,9 @@ mod tests { match app .clone() .oneshot( - super::request::run_post(None, &uri, axum::http::Method::GET, false).await.unwrap() + super::request::run_post(None, &uri, axum::http::Method::GET, false) + .await + .unwrap(), ) .await { @@ -2160,7 +2181,9 @@ mod tests { match app .clone() .oneshot( - super::request::run_post(None, &uri, axum::http::Method::GET, false).await.unwrap() + super::request::run_post(None, &uri, axum::http::Method::GET, false) + .await + .unwrap(), ) .await { @@ -2214,7 +2237,9 @@ mod tests { match app .clone() .oneshot( - super::request::run_post(None, &uri, axum::http::Method::GET, false).await.unwrap() + super::request::run_post(None, &uri, axum::http::Method::GET, false) + .await + .unwrap(), ) .await { @@ -2333,7 +2358,9 @@ mod tests { match app .clone() .oneshot( - super::request::run_post(None, &uri, axum::http::Method::DELETE, false).await.unwrap() + super::request::run_post(None, &uri, axum::http::Method::DELETE, false) + .await + .unwrap(), ) .await { -- 2.47.3 From d2d0a7c3948462595af110fef531ae124fb98040 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 16:30:26 -0400 Subject: [PATCH 10/14] Fix --- src/main.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main.rs b/src/main.rs index 52e801a..86936a5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,9 +25,11 @@ 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; -- 2.47.3 From 3c482aba3a87b86c537cba5e044e9a972d2c50b1 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 16:40:42 -0400 Subject: [PATCH 11/14] Cleanup --- src/main.rs | 53 +++++++++++------------------------------------------ 1 file changed, 11 insertions(+), 42 deletions(-) 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 { -- 2.47.3 From 06cf199d17cb939defc9e1c094d0f10df619ce2b Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 16:44:05 -0400 Subject: [PATCH 12/14] Cleanup --- src/main.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0c449eb..b78eb13 100644 --- a/src/main.rs +++ b/src/main.rs @@ -456,7 +456,6 @@ mod tests { } pub async fn run_post( - // payload: Option<&serde_json::Value>, payload: Option, uri: &str, method: axum::http::Method, @@ -553,10 +552,7 @@ mod tests { Err(err) => Err(err), } } - Err(err) => { - assert!(false, "Error: {:?}", err); - Err(err) - } + Err(err) => Err(err), } } Err(err) => Err(err), @@ -606,16 +602,10 @@ mod tests { Err(err) => Err(err), } } - Err(err) => { - assert!(false, "Error: {:?}", err); - Err(err) - } + Err(err) => Err(err), } } - Err(err) => { - assert!(false, "Error: {:?}", err); - Err(err) - } + Err(err) => Err(err), } } @@ -778,10 +768,8 @@ 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) @@ -790,7 +778,6 @@ mod tests { assert_eq!(false, resp.data[0].is_nil(), "Should not be empty"); } Err(err) => { - eprintln!("Failure!"); assert!(false, "Error: {:?}", err); } }; -- 2.47.3 From 578e278cf921f4ef29e5fd59547c22cbd4b46982 Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 16:44:12 -0400 Subject: [PATCH 13/14] bump: labyrinth --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 177c56e..13f1850 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1938,7 +1938,7 @@ checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37" [[package]] name = "labyrinth" version = "0.0.3" -source = "git+ssh://git@git.kundeng.us/phoenix/labyrinth.git?tag=v0.0.3-3-f99a77ece0-928#f99a77ece0d066ee96867936eb280db367354e0a" +source = "git+ssh://git@git.kundeng.us/phoenix/labyrinth.git?tag=v0.0.3#6ed1d00a32c62d5add4adbcc73a49027c53e697c" dependencies = [ "aws-config", "aws-sdk-s3", diff --git a/Cargo.toml b/Cargo.toml index c1c3299..1630bd2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] } simeta = { git = "ssh://git@git.kundeng.us/phoenix/simeta.git", tag = "v0.6.1-main-b690995806-680" } simodels = { git = "ssh://git@git.kundeng.us/phoenix/simodels.git", tag = "v0.11.3-main-fe9d101bd0-111" } sienvy = { git = "ssh://git@git.kundeng.us/phoenix/sienvy.git", tag = "v0.8.0-main-d06c8fdf49-006" } -labyrinth = { git = "ssh://git@git.kundeng.us/phoenix/labyrinth.git", tag = "v0.0.3-3-f99a77ece0-928" } +labyrinth = { git = "ssh://git@git.kundeng.us/phoenix/labyrinth.git", tag = "v0.0.3" } [dev-dependencies] common-multipart-rfc7578 = { version = "0.7.0" } -- 2.47.3 From a4438c289dafa73e784b40cee23eafba1f26d55f Mon Sep 17 00:00:00 2001 From: phoenix Date: Wed, 12 Aug 2026 16:48:50 -0400 Subject: [PATCH 14/14] bump: labyrinth --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 13f1850..baeb1f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1937,8 +1937,8 @@ checksum = "a4933f3f57a8e9d9da04db23fb153356ecaf00cbd14aee46279c33dc80925c37" [[package]] name = "labyrinth" -version = "0.0.3" -source = "git+ssh://git@git.kundeng.us/phoenix/labyrinth.git?tag=v0.0.3#6ed1d00a32c62d5add4adbcc73a49027c53e697c" +version = "0.0.4" +source = "git+ssh://git@git.kundeng.us/phoenix/labyrinth.git?tag=v0.0.4#f406ed196145bb667587c13f4fd0866a1fa6e915" dependencies = [ "aws-config", "aws-sdk-s3", diff --git a/Cargo.toml b/Cargo.toml index 1630bd2..59259dd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -29,7 +29,7 @@ utoipa-swagger-ui = { version = "9.0.2", features = ["axum"] } simeta = { git = "ssh://git@git.kundeng.us/phoenix/simeta.git", tag = "v0.6.1-main-b690995806-680" } simodels = { git = "ssh://git@git.kundeng.us/phoenix/simodels.git", tag = "v0.11.3-main-fe9d101bd0-111" } sienvy = { git = "ssh://git@git.kundeng.us/phoenix/sienvy.git", tag = "v0.8.0-main-d06c8fdf49-006" } -labyrinth = { git = "ssh://git@git.kundeng.us/phoenix/labyrinth.git", tag = "v0.0.3" } +labyrinth = { git = "ssh://git@git.kundeng.us/phoenix/labyrinth.git", tag = "v0.0.4" } [dev-dependencies] common-multipart-rfc7578 = { version = "0.7.0" } -- 2.47.3