diff --git a/src/main.rs b/src/main.rs index e0d7eae..993b5b5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -302,6 +302,22 @@ mod tests { 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!( + { + "song_queue_id": song_queue_id, + "coverart_id" : coverart_id, + }); + let req = axum::http::Request::builder() + .method(axum::http::Method::PATCH) + .uri(crate::callers::endpoints::QUEUECOVERARTLINK) + .header(axum::http::header::CONTENT_TYPE, "application/json") + .body(axum::body::Body::from(payload.to_string())) + .unwrap(); + + app.clone().oneshot(req).await + } + pub async fn resp_to_bytes( response: axum::response::Response, ) -> Result { @@ -702,23 +718,7 @@ mod tests { let coverart_id = resp.data[0]; assert_eq!(false, coverart_id.is_nil(), "Should not be empty"); - let payload = serde_json::json!( - { - "song_queue_id": song_queue_id, - "coverart_id" : coverart_id, - }); - - match app - .clone() - .oneshot( - axum::http::Request::builder() - .method(axum::http::Method::PATCH) - .uri(crate::callers::endpoints::QUEUECOVERARTLINK) - .header(axum::http::header::CONTENT_TYPE, "application/json") - .body(axum::body::Body::from(payload.to_string())) - .unwrap(), - ) - .await + match coverart_queue_song_queue_link_req(&app, &coverart_id, &song_queue_id).await { Ok(response) => { let resp = get_resp_data::<