From a80e21b918b9493b868f2e4d93bb8398d644b334 Mon Sep 17 00:00:00 2001 From: KD Date: Mon, 3 Nov 2025 13:41:56 -0500 Subject: [PATCH] tsk-204: Changing name of test payload function (#239) * tsk-204: Changing name of test payload function * tsk-204: Added more test payload functions * tsk-204: Version bump --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/main.rs | 72 ++++++++++++++++++++++++++++++++++++++--------------- 3 files changed, 54 insertions(+), 22 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index fc1cc3b..f12a209 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -964,7 +964,7 @@ dependencies = [ [[package]] name = "icarus" -version = "0.3.21" +version = "0.3.22" dependencies = [ "axum", "axum-extra", diff --git a/Cargo.toml b/Cargo.toml index b19c709..7cf2864 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "icarus" -version = "0.3.21" +version = "0.3.22" edition = "2024" rust-version = "1.90" diff --git a/src/main.rs b/src/main.rs index ae721f1..f6d0890 100644 --- a/src/main.rs +++ b/src/main.rs @@ -497,10 +497,8 @@ mod tests { 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 - }); + 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) @@ -612,7 +610,7 @@ mod tests { app: &axum::Router, song_queue_id: &uuid::Uuid, ) -> Result { - let payload = super::payload_data::queue_metadata_payload_data(&song_queue_id).await; + let payload = super::payload_data::queue_metadata(&song_queue_id).await; let req = axum::http::Request::builder() .method(axum::http::Method::POST) @@ -633,11 +631,11 @@ mod tests { 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 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) @@ -657,10 +655,8 @@ mod tests { song_id: &uuid::Uuid, coverart_id: &uuid::Uuid, ) -> Result { - let payload = serde_json::json!({ - "song_id": song_id, - "coverart_queue_id": coverart_id - }); + 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) @@ -699,10 +695,8 @@ mod tests { 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 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) @@ -902,9 +896,8 @@ mod tests { } } - // TODO: Change the name of the function to be more expressive and put into it's own module pub mod payload_data { - pub async fn queue_metadata_payload_data(song_queue_id: &uuid::Uuid) -> serde_json::Value { + pub async fn queue_metadata(song_queue_id: &uuid::Uuid) -> serde_json::Value { serde_json::json!( { "song_queue_id": song_queue_id, @@ -943,6 +936,45 @@ mod tests { "song_queue_id": song_queue_id }) } + + pub async fn link_user_to_queued_song( + song_queue_id: &uuid::Uuid, + user_id: &uuid::Uuid, + ) -> serde_json::Value { + serde_json::json!({ + "song_queue_id": song_queue_id, + "user_id": user_id + }) + } + + pub async fn link_queued_coverart_to_queued_song( + song_queue_id: &uuid::Uuid, + coverart_queue_id: &uuid::Uuid, + ) -> serde_json::Value { + serde_json::json!({ + "song_queue_id": song_queue_id, + "coverart_id": coverart_queue_id + }) + } + + pub async fn create_coverart( + song_id: &uuid::Uuid, + coverart_queue_id: &uuid::Uuid, + ) -> serde_json::Value { + serde_json::json!({ + "song_id": song_id, + "coverart_queue_id": coverart_queue_id + }) + } + + pub async fn update_song_queue_status_to_ready( + song_queue_id: &uuid::Uuid, + ) -> serde_json::Value { + serde_json::json!({ + "id": song_queue_id, + "status": crate::repo::queue::song::status::READY + }) + } } #[tokio::test]