diff --git a/src/callers/song.rs b/src/callers/song.rs index cc7ce36..0f4872d 100644 --- a/src/callers/song.rs +++ b/src/callers/song.rs @@ -226,7 +226,8 @@ pub mod endpoint { pub async fn download_flac( axum::Extension(pool): axum::Extension, - axum::extract::Path(id): axum::extract::Path) -> (StatusCode, axum::response::Response) { + axum::extract::Path(id): axum::extract::Path, + ) -> (StatusCode, axum::response::Response) { println!("Id: {:?}", id); match song_queue::get_data(&pool, &id).await { @@ -240,14 +241,14 @@ pub mod endpoint { ); headers.insert( axum::http::header::CONTENT_DISPOSITION, - format!("attachment; filename=\"{}.flac\"", id).parse().unwrap(), + format!("attachment; filename=\"{}.flac\"", id) + .parse() + .unwrap(), ); (StatusCode::OK, response) } - Err(_err) => { - (StatusCode::BAD_REQUEST, axum::response::Response::default()) - } + Err(_err) => (StatusCode::BAD_REQUEST, axum::response::Response::default()), } } } diff --git a/src/main.rs b/src/main.rs index 837d6bd..5a12085 100644 --- a/src/main.rs +++ b/src/main.rs @@ -231,17 +231,22 @@ mod tests { 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::endpoints::NEXTQUEUESONG) - .header(axum::http::header::CONTENT_TYPE, "application/json") - .body(axum::body::Body::empty()) - .unwrap(); + async fn fetch_queue_req( + app: &axum::Router, + ) -> Result { + let fetch_req = axum::http::Request::builder() + .method(axum::http::Method::GET) + .uri(crate::callers::endpoints::NEXTQUEUESONG) + .header(axum::http::header::CONTENT_TYPE, "application/json") + .body(axum::body::Body::empty()) + .unwrap(); app.clone().oneshot(fetch_req).await } - async fn fetch_queue_data_req(app: &axum::Router, id: &uuid::Uuid) -> Result { + async fn fetch_queue_data_req( + app: &axum::Router, + id: &uuid::Uuid, + ) -> Result { let raw_uri = String::from(crate::callers::endpoints::QUEUESONGDATA); let end_index = raw_uri.len() - 4; let mut uri: String = (&raw_uri[..end_index]).to_string(); @@ -256,18 +261,17 @@ mod tests { app.clone().oneshot(req).await } - pub async fn resp_to_bytes(response: axum::response::Response) -> Result { - axum::body::to_bytes(response.into_body(), usize::MAX) - .await + pub async fn resp_to_bytes( + response: axum::response::Response, + ) -> Result { + axum::body::to_bytes(response.into_body(), usize::MAX).await } pub async fn get_resp_data(response: axum::response::Response) -> Data where Data: for<'a> serde::Deserialize<'a>, { - let body = resp_to_bytes(response) - .await - .unwrap(); + let body = resp_to_bytes(response).await.unwrap(); serde_json::from_slice(&body).unwrap() } @@ -391,16 +395,18 @@ mod tests { let id = resp.data[0].id; match fetch_queue_data_req(&app, &id).await { - Ok(response) => { - match resp_to_bytes(response).await { - Ok(bytes) => { - assert_eq!(false, bytes.is_empty(), "Queued data should not be empty"); - } - Err(err) => { - assert!(false, "Error: {:?}", err); - } + Ok(response) => match resp_to_bytes(response).await { + Ok(bytes) => { + assert_eq!( + false, + bytes.is_empty(), + "Queued data should not be empty" + ); } - } + Err(err) => { + assert!(false, "Error: {:?}", err); + } + }, Err(err) => { assert!(false, "Error: {:?}", err); }