From 8973838288f0e8b974b416c2b1653806acb828f3 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Sun, 2 Nov 2025 21:04:42 -0500 Subject: [PATCH 1/6] tsk-206: Moving request functions to their own module in testing --- src/main.rs | 493 ++++++++++++++++++++++++++-------------------------- 1 file changed, 251 insertions(+), 242 deletions(-) diff --git a/src/main.rs b/src/main.rs index 93b4b6e..69239a2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -463,244 +463,252 @@ mod tests { format!("Bearer {token}") } - // TODO: Put the *_req() functions in their own module - async fn song_queue_req( - app: &axum::Router, - ) -> Result { - // Create multipart form - let mut form = MultipartForm::default(); - let _ = form.add_file("flac", "tests/I/track01.flac"); + mod request { + use common_multipart_rfc7578::client::multipart::{ + Body as MultipartBody, Form as MultipartForm, + }; + use tower::ServiceExt; - // 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, bearer_auth().await) - .body(axum::body::Body::from_stream(body)) - .unwrap(); - app.clone().oneshot(req).await - } - async fn song_queue_link_req( - app: &axum::Router, - song_queue_id: &uuid::Uuid, - user_id: &uuid::Uuid, - ) -> Result { - let payload = serde_json::json!({ - "song_queue_id": song_queue_id, - "user_id": user_id - }); + pub async fn song_queue_req( + app: &axum::Router, + ) -> Result { + // Create multipart form + let mut form = MultipartForm::default(); + let _ = form.add_file("flac", "tests/I/track01.flac"); - 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, bearer_auth().await) - .body(axum::body::Body::from(payload.to_string())) - .unwrap(); + // 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 + } - app.clone().oneshot(req).await - } - - 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, bearer_auth().await) - .body(axum::body::Body::empty()) - .unwrap(); - app.clone().oneshot(fetch_req).await - } - - async fn fetch_metadata_queue_req( - app: &axum::Router, - id: &uuid::Uuid, - ) -> 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, bearer_auth().await) - .body(axum::body::Body::empty()) - .unwrap(); - - app.clone().oneshot(req).await - } - - async fn fetch_queue_data_req( - app: &axum::Router, - id: &uuid::Uuid, - ) -> 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, "audio/flac") - .header(axum::http::header::AUTHORIZATION, bearer_auth().await) - .body(axum::body::Body::empty()) - .unwrap(); - - app.clone().oneshot(req).await - } - - async fn upload_coverart_queue_req( - app: &axum::Router, - ) -> Result { - let mut form = MultipartForm::default(); - let _ = form.add_file("jpg", "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, bearer_auth().await) - .body(axum::body::Body::from_stream(body)) - .unwrap(); - - app.clone().oneshot(req).await - } - - async fn queue_metadata_req( - app: &axum::Router, - song_queue_id: &uuid::Uuid, - ) -> Result { - let payload = payload_data::queue_metadata_payload_data(&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, bearer_auth().await) - .body(axum::body::Body::from(payload.to_string())) - .unwrap(); - - app.clone().oneshot(req).await - } - - async fn coverart_queue_song_queue_link_req( - app: &axum::Router, - coverart_id: &uuid::Uuid, - song_queue_id: &uuid::Uuid, - ) -> Result { - let payload = serde_json::json!( - { + pub async fn song_queue_link_req( + app: &axum::Router, + song_queue_id: &uuid::Uuid, + user_id: &uuid::Uuid, + ) -> Result { + let payload = serde_json::json!({ "song_queue_id": song_queue_id, - "coverart_id" : coverart_id, - }); - 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, bearer_auth().await) - .body(axum::body::Body::from(payload.to_string())) - .unwrap(); + "user_id": user_id + }); - app.clone().oneshot(req).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 + } + + 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 + } + + pub async fn fetch_metadata_queue_req( + app: &axum::Router, + id: &uuid::Uuid, + ) -> 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 + } + + pub async fn fetch_queue_data_req( + app: &axum::Router, + id: &uuid::Uuid, + ) -> 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, "audio/flac") + .header(axum::http::header::AUTHORIZATION, super::bearer_auth().await) + .body(axum::body::Body::empty()) + .unwrap(); + + app.clone().oneshot(req).await + } + + pub async fn upload_coverart_queue_req( + app: &axum::Router, + ) -> Result { + let mut form = MultipartForm::default(); + let _ = form.add_file("jpg", "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 + } + + pub async fn queue_metadata_req( + app: &axum::Router, + song_queue_id: &uuid::Uuid, + ) -> Result { + let payload = super::payload_data::queue_metadata_payload_data(&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 + } + + pub async fn coverart_queue_song_queue_link_req( + app: &axum::Router, + coverart_id: &uuid::Uuid, + song_queue_id: &uuid::Uuid, + ) -> Result { + let payload = serde_json::json!( + { + "song_queue_id": song_queue_id, + "coverart_id" : coverart_id, + }); + 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 + } + + pub async fn create_coverart_req( + app: &axum::Router, + song_id: &uuid::Uuid, + coverart_id: &uuid::Uuid, + ) -> Result { + let payload = serde_json::json!({ + "song_id": song_id, + "coverart_queue_id": coverart_id + }); + 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 + } + + pub async fn create_song_req( + app: &axum::Router, + song_queue_id: &uuid::Uuid, + user_id: &uuid::Uuid, + ) -> 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 + } + + pub async fn update_song_queue_status_req( + app: &axum::Router, + song_queue_id: &uuid::Uuid, + ) -> Result { + let payload = serde_json::json!({ + "id": &song_queue_id, + "status": crate::repo::queue::song::status::READY + }); + + 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 + } + + pub async fn get_queued_coverart( + app: &axum::Router, + coverart_queue_id: &uuid::Uuid, + ) -> Result { + let uri = format!( + "{}?id={}", + crate::callers::queue::endpoints::QUEUECOVERART, + coverart_queue_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 + } } - async fn create_coverart_req( - app: &axum::Router, - song_id: &uuid::Uuid, - coverart_id: &uuid::Uuid, - ) -> Result { - let payload = serde_json::json!({ - "song_id": song_id, - "coverart_queue_id": coverart_id - }); - 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, bearer_auth().await) - .body(axum::body::Body::from(payload.to_string())) - .unwrap(); - app.clone().oneshot(req).await - } - - async fn create_song_req( - app: &axum::Router, - song_queue_id: &uuid::Uuid, - user_id: &uuid::Uuid, - ) -> Result { - let payload = 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, bearer_auth().await) - .body(axum::body::Body::from(payload.to_string())) - .unwrap(); - - app.clone().oneshot(req).await - } - - async fn update_song_queue_status_req( - app: &axum::Router, - song_queue_id: &uuid::Uuid, - ) -> Result { - let payload = serde_json::json!({ - "id": &song_queue_id, - "status": crate::repo::queue::song::status::READY - }); - - 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, bearer_auth().await) - .body(axum::body::Body::from(payload.to_string())) - .unwrap(); - - app.clone().oneshot(req).await - } - - async fn get_queued_coverart( - app: &axum::Router, - coverart_queue_id: &uuid::Uuid, - ) -> Result { - let uri = format!( - "{}?id={}", - crate::callers::queue::endpoints::QUEUECOVERART, - coverart_queue_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, bearer_auth().await) - .body(axum::body::Body::empty()) - .unwrap(); - - app.clone().oneshot(req).await - } mod sequence_flow { // Flow for queueing song pub async fn queue_song_flow( app: &axum::Router, ) -> Result<(axum::response::Response, uuid::Uuid), std::convert::Infallible> { - match super::song_queue_req(&app).await { + match super::request::song_queue_req(&app).await { Ok(response) => { let resp = super::util::get_resp_data::< crate::callers::queue::song::response::song_queue::Response, @@ -713,7 +721,7 @@ mod tests { let user_id = super::TEST_USER_ID; - match super::song_queue_link_req(&app, &song_queue_id, &user_id).await { + match super::request::song_queue_link_req(&app, &song_queue_id, &user_id).await { Ok(response) => { let resp = super::util::get_resp_data::< crate::callers::queue::song::response::link_user_id::Response, @@ -725,7 +733,7 @@ mod tests { "The response should not be empty" ); - match super::queue_metadata_req(&app, &song_queue_id).await { + match super::request::queue_metadata_req(&app, &song_queue_id).await { Ok(response) => { let resp = super::util::get_resp_data::< crate::callers::queue::song::response::song_queue::Response, @@ -735,7 +743,7 @@ mod tests { let id = resp.data[0]; - match super::fetch_metadata_queue_req(&app, &id).await { + match super::request::fetch_metadata_queue_req(&app, &id).await { Ok(response) => Ok((response, user_id)), Err(err) => Err(err), } @@ -754,7 +762,7 @@ mod tests { app: &axum::Router, song_queue_id: &uuid::Uuid, ) -> Result { - match super::upload_coverart_queue_req(&app).await { + match super::request::upload_coverart_queue_req(&app).await { Ok(response) => { let resp = super::util::get_resp_data::< crate::callers::queue::coverart::response::queue::Response, @@ -764,7 +772,7 @@ mod tests { let coverart_id = resp.data[0]; assert_eq!(false, coverart_id.is_nil(), "Should not be empty"); - match super::coverart_queue_song_queue_link_req( + match super::request::coverart_queue_song_queue_link_req( &app, &coverart_id, &song_queue_id, @@ -783,7 +791,7 @@ mod tests { assert_eq!(false, resp_coverart_id.is_nil(), "Should not be empty"); assert_eq!(false, resp_song_queue_id.is_nil(), "Should not be empty"); - match super::get_queued_coverart(&app, &resp_coverart_id).await { + match super::request::get_queued_coverart(&app, &resp_coverart_id).await { Ok(response) => Ok(response), Err(err) => Err(err), } @@ -806,7 +814,7 @@ mod tests { assert_eq!(false, resp.data.is_empty(), "Data should not be empty"); let song_queue_id = resp.data[0].song_queue_id; - match super::create_song_req(&app, &song_queue_id, &user_id).await { + match super::request::create_song_req(&app, &song_queue_id, &user_id).await { Ok(response) => { let resp = super::util::get_resp_data::< crate::callers::song::response::create_metadata::Response, @@ -914,7 +922,7 @@ mod tests { let app = init::app(pool).await; // Send request - match song_queue_req(&app).await { + match request::song_queue_req(&app).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::song::response::song_queue::Response, @@ -950,7 +958,7 @@ mod tests { let app = init::app(pool).await; - match song_queue_req(&app).await { + match request::song_queue_req(&app).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::song::response::song_queue::Response, @@ -963,7 +971,7 @@ mod tests { let user_id = TEST_USER_ID; println!("User Id: {user_id:?}"); - match song_queue_link_req(&app, &song_queue_id, &user_id).await { + match request::song_queue_link_req(&app, &song_queue_id, &user_id).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::song::response::link_user_id::Response, @@ -1028,7 +1036,7 @@ mod tests { let old = crate::repo::queue::song::status::PENDING; let target_status = crate::repo::queue::song::status::READY; - match update_song_queue_status_req(&app, &song_queue_id).await { + match request::update_song_queue_status_req(&app, &song_queue_id).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::song::response::update_status::Response, @@ -1043,7 +1051,7 @@ mod tests { "New status does not match" ); - match fetch_queue_req(&app).await { + match request::fetch_queue_req(&app).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::song::response::fetch_queue_song::Response, @@ -1089,7 +1097,7 @@ mod tests { let app = init::app(pool).await; // Send request - match song_queue_req(&app).await { + match request::song_queue_req(&app).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::song::response::song_queue::Response, @@ -1100,7 +1108,7 @@ mod tests { let id = &resp.data[0]; - match fetch_queue_data_req(&app, &id).await { + match request::fetch_queue_data_req(&app, &id).await { Ok(response) => match util::resp_to_bytes(response).await { Ok(bytes) => { assert_eq!(false, bytes.is_empty(), "Queued data should not be empty"); @@ -1714,7 +1722,7 @@ mod tests { assert_eq!(false, resp.data.is_empty(), "Data should not be empty"); let song_q_id = resp.data[0].song_queue_id; - match create_song_req(&app, &song_q_id, &user_id).await { + match request::create_song_req(&app, &song_q_id, &user_id).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::song::response::create_metadata::Response, @@ -1777,7 +1785,7 @@ mod tests { assert_eq!(false, resp.data.is_empty(), "Data should not be empty"); let song_queue_id = resp.data[0].song_queue_id; - match create_song_req(&app, &song_queue_id, &user_id).await { + match request::create_song_req(&app, &song_queue_id, &user_id).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::song::response::create_metadata::Response, @@ -1807,7 +1815,7 @@ mod tests { assert_eq!(false, resp.data.is_empty(), "Should not be empty"); let resp_queue_coverart_id = resp.data[0].id; - match create_coverart_req(&app, &song_id, &resp_queue_coverart_id) + match request::create_coverart_req(&app, &song_id, &resp_queue_coverart_id) .await { Ok(response) => { @@ -1976,7 +1984,7 @@ mod tests { assert_eq!(false, resp.data.is_empty(), "Data should not be empty"); let song_queue_id = resp.data[0].song_queue_id; - match create_song_req(&app, &song_queue_id, &user_id).await { + match request::create_song_req(&app, &song_queue_id, &user_id).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::song::response::create_metadata::Response, @@ -2070,6 +2078,7 @@ mod tests { use futures::StreamExt; use tower::ServiceExt; + #[tokio::test] async fn test_get_songs() { let tm_pool = super::db_mgr::get_pool().await.unwrap(); -- 2.47.3 From bbafd2abd111dd8d1e531a67ce709e285fa1b715 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Sun, 2 Nov 2025 21:05:25 -0500 Subject: [PATCH 2/6] tsk-206: Version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 99cb6d8..fc1cc3b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -964,7 +964,7 @@ dependencies = [ [[package]] name = "icarus" -version = "0.3.20" +version = "0.3.21" dependencies = [ "axum", "axum-extra", diff --git a/Cargo.toml b/Cargo.toml index a90c003..b19c709 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "icarus" -version = "0.3.20" +version = "0.3.21" edition = "2024" rust-version = "1.90" -- 2.47.3 From 1fdddf99d8fd6c21bd0e5c2e7575dbcdae92b386 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Sun, 2 Nov 2025 21:09:33 -0500 Subject: [PATCH 3/6] tsk-206: Forgot some imports. Some cleanup --- src/main.rs | 102 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 76 insertions(+), 26 deletions(-) diff --git a/src/main.rs b/src/main.rs index 69239a2..d126d06 100644 --- a/src/main.rs +++ b/src/main.rs @@ -469,7 +469,6 @@ mod tests { }; use tower::ServiceExt; - pub async fn song_queue_req( app: &axum::Router, ) -> Result { @@ -484,7 +483,10 @@ mod tests { .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) + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) .body(axum::body::Body::from_stream(body)) .unwrap(); app.clone().oneshot(req).await @@ -504,7 +506,10 @@ mod tests { .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) + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) .body(axum::body::Body::from(payload.to_string())) .unwrap(); @@ -518,7 +523,10 @@ mod tests { .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) + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) .body(axum::body::Body::empty()) .unwrap(); app.clone().oneshot(fetch_req).await @@ -538,7 +546,10 @@ mod tests { .method(axum::http::Method::GET) .uri(uri) .header(axum::http::header::CONTENT_TYPE, "application/json") - .header(axum::http::header::AUTHORIZATION, super::bearer_auth().await) + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) .body(axum::body::Body::empty()) .unwrap(); @@ -556,8 +567,14 @@ mod tests { let req = axum::http::Request::builder() .method(axum::http::Method::GET) .uri(uri) - .header(axum::http::header::CONTENT_TYPE, "audio/flac") - .header(axum::http::header::AUTHORIZATION, super::bearer_auth().await) + .header( + axum::http::header::CONTENT_TYPE, + icarus_meta::detection::song::constants::mime::FLAC, + ) + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) .body(axum::body::Body::empty()) .unwrap(); @@ -568,7 +585,10 @@ mod tests { app: &axum::Router, ) -> Result { let mut form = MultipartForm::default(); - let _ = form.add_file("jpg", "tests/I/Coverart-1.jpg"); + let _ = form.add_file( + icarus_meta::detection::coverart::constants::JPEG_TYPE, + "tests/I/Coverart-1.jpg", + ); // Create request let content_type = form.content_type(); @@ -578,7 +598,10 @@ mod tests { .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) + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) .body(axum::body::Body::from_stream(body)) .unwrap(); @@ -595,7 +618,10 @@ mod tests { .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) + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) .body(axum::body::Body::from(payload.to_string())) .unwrap(); @@ -616,7 +642,10 @@ mod tests { .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) + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) .body(axum::body::Body::from(payload.to_string())) .unwrap(); @@ -636,7 +665,10 @@ mod tests { .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) + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) .body(axum::body::Body::from(payload.to_string())) .unwrap(); app.clone().oneshot(req).await @@ -653,7 +685,10 @@ mod tests { .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) + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) .body(axum::body::Body::from(payload.to_string())) .unwrap(); @@ -673,7 +708,10 @@ mod tests { .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) + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) .body(axum::body::Body::from(payload.to_string())) .unwrap(); @@ -694,7 +732,10 @@ mod tests { .method(axum::http::Method::GET) .uri(uri) .header(axum::http::header::CONTENT_TYPE, "application/json") - .header(axum::http::header::AUTHORIZATION, super::bearer_auth().await) + .header( + axum::http::header::AUTHORIZATION, + super::bearer_auth().await, + ) .body(axum::body::Body::empty()) .unwrap(); @@ -702,7 +743,6 @@ mod tests { } } - mod sequence_flow { // Flow for queueing song pub async fn queue_song_flow( @@ -721,7 +761,8 @@ mod tests { let user_id = super::TEST_USER_ID; - match super::request::song_queue_link_req(&app, &song_queue_id, &user_id).await { + match super::request::song_queue_link_req(&app, &song_queue_id, &user_id).await + { Ok(response) => { let resp = super::util::get_resp_data::< crate::callers::queue::song::response::link_user_id::Response, @@ -743,7 +784,8 @@ mod tests { let id = resp.data[0]; - match super::request::fetch_metadata_queue_req(&app, &id).await { + match super::request::fetch_metadata_queue_req(&app, &id).await + { Ok(response) => Ok((response, user_id)), Err(err) => Err(err), } @@ -791,7 +833,8 @@ mod tests { assert_eq!(false, resp_coverart_id.is_nil(), "Should not be empty"); assert_eq!(false, resp_song_queue_id.is_nil(), "Should not be empty"); - match super::request::get_queued_coverart(&app, &resp_coverart_id).await { + match super::request::get_queued_coverart(&app, &resp_coverart_id).await + { Ok(response) => Ok(response), Err(err) => Err(err), } @@ -1455,7 +1498,7 @@ mod tests { let app = init::app(pool).await; - match song_queue_req(&app).await { + match request::song_queue_req(&app).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::coverart::response::queue::Response, @@ -1466,7 +1509,7 @@ mod tests { assert_eq!(false, song_queue_id.is_nil(), "Should not be empty"); // Send request - match upload_coverart_queue_req(&app).await { + match request::upload_coverart_queue_req(&app).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::coverart::response::queue::Response, @@ -1476,8 +1519,12 @@ mod tests { let coverart_id = resp.data[0]; assert_eq!(false, coverart_id.is_nil(), "Should not be empty"); - match coverart_queue_song_queue_link_req(&app, &coverart_id, &song_queue_id) - .await + match request::coverart_queue_song_queue_link_req( + &app, + &coverart_id, + &song_queue_id, + ) + .await { Ok(response) => { let resp = util::get_resp_data::< @@ -1815,8 +1862,12 @@ mod tests { assert_eq!(false, resp.data.is_empty(), "Should not be empty"); let resp_queue_coverart_id = resp.data[0].id; - match request::create_coverart_req(&app, &song_id, &resp_queue_coverart_id) - .await + match request::create_coverart_req( + &app, + &song_id, + &resp_queue_coverart_id, + ) + .await { Ok(response) => { let resp = util::get_resp_data::< @@ -2078,7 +2129,6 @@ mod tests { use futures::StreamExt; use tower::ServiceExt; - #[tokio::test] async fn test_get_songs() { let tm_pool = super::db_mgr::get_pool().await.unwrap(); -- 2.47.3 From e483e1edfe4051fc216e3c87459a2bef4d2cd5d3 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Sun, 2 Nov 2025 21:14:40 -0500 Subject: [PATCH 4/6] tsk-206: Forgot some imports --- src/main.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index d126d06..3265c73 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1579,7 +1579,7 @@ mod tests { let app = init::app(pool).await; - match song_queue_req(&app).await { + match request::song_queue_req(&app).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::coverart::response::queue::Response, @@ -1629,7 +1629,7 @@ mod tests { let app = init::app(pool).await; - match song_queue_req(&app).await { + match request::song_queue_req(&app).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::coverart::response::queue::Response, @@ -1640,7 +1640,7 @@ mod tests { assert_eq!(false, song_queue_id.is_nil(), "Should not be empty"); // Send request - match upload_coverart_queue_req(&app).await { + match request::upload_coverart_queue_req(&app).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::coverart::response::queue::Response, @@ -1650,8 +1650,12 @@ mod tests { let coverart_id = resp.data[0]; assert_eq!(false, coverart_id.is_nil(), "Should not be empty"); - match coverart_queue_song_queue_link_req(&app, &coverart_id, &song_queue_id) - .await + match request::coverart_queue_song_queue_link_req( + &app, + &coverart_id, + &song_queue_id, + ) + .await { Ok(response) => { let resp = util::get_resp_data::< -- 2.47.3 From 02ee889ff460e8ab8f5fe292965e255cdc6c2ad6 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Sun, 2 Nov 2025 21:19:46 -0500 Subject: [PATCH 5/6] tsk-206: How did I miss these? --- src/main.rs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index 3265c73..15e2167 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1266,7 +1266,7 @@ mod tests { let app = init::app(pool).await; // Send request - match song_queue_req(&app).await { + match request::song_queue_req(&app).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::song::response::song_queue::Response, @@ -1276,7 +1276,7 @@ mod tests { assert_eq!(false, resp.data[0].is_nil(), "Should not be empty"); let id = resp.data[0]; - match fetch_queue_data_req(&app, &id).await { + match request:: fetch_queue_data_req(&app, &id).await { Ok(response) => match util::resp_to_bytes(response).await { Ok(bytes) => { assert_eq!(false, bytes.is_empty(), "Queued data should not be empty"); @@ -1330,7 +1330,7 @@ mod tests { let old = crate::repo::queue::song::status::PENDING; let done = crate::repo::queue::song::status::READY; - match update_song_queue_status_req(&app, &song_queue_id).await { + match request::update_song_queue_status_req(&app, &song_queue_id).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::song::response::update_status::Response, @@ -1375,7 +1375,7 @@ mod tests { let app = init::app(pool).await; // Send request - match song_queue_req(&app).await { + match request::song_queue_req(&app).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::song::response::song_queue::Response, @@ -1384,7 +1384,7 @@ mod tests { assert_eq!(false, resp.data.is_empty(), "Should not be empty"); assert_eq!(false, resp.data[0].is_nil(), "Should not be empty"); - match queue_metadata_req(&app, &resp.data[0]).await { + match request::queue_metadata_req(&app, &resp.data[0]).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::song::response::song_queue::Response, @@ -1461,7 +1461,7 @@ mod tests { let app = init::app(pool).await; // Send request - match upload_coverart_queue_req(&app).await { + match request::upload_coverart_queue_req(&app).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::queue::coverart::response::queue::Response, @@ -1933,7 +1933,7 @@ mod tests { assert_eq!(false, resp.data.is_empty(), "Data should not be empty"); let song_q_id = resp.data[0].song_queue_id; - match create_song_req(&app, &song_q_id, &user_id).await { + match request::create_song_req(&app, &song_q_id, &user_id).await { Ok(response) => { let resp = util::get_resp_data::< crate::callers::song::response::create_metadata::Response, -- 2.47.3 From 77d5ce51baca31be1b017317de24150e826b5621 Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Sun, 2 Nov 2025 21:25:21 -0500 Subject: [PATCH 6/6] tsk-206: Code formatting --- src/main.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 15e2167..ae721f1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1276,7 +1276,7 @@ mod tests { assert_eq!(false, resp.data[0].is_nil(), "Should not be empty"); let id = resp.data[0]; - match request:: fetch_queue_data_req(&app, &id).await { + match request::fetch_queue_data_req(&app, &id).await { Ok(response) => match util::resp_to_bytes(response).await { Ok(bytes) => { assert_eq!(false, bytes.is_empty(), "Queued data should not be empty"); -- 2.47.3