Download coverart endpoint (#166)

* Added download coverart endpoint

* Endpoint is now available

* Added test

* Code formatting

* Version bump
This commit was merged in pull request #166.
This commit is contained in:
KD
2025-07-28 17:05:42 -04:00
committed by GitHub
parent 703fc49f32
commit c7230d3b32
5 changed files with 99 additions and 2 deletions
+60
View File
@@ -123,6 +123,10 @@ pub mod init {
crate::callers::endpoints::GETCOVERART,
get(crate::callers::coverart::endpoint::get_coverart),
)
.route(
crate::callers::endpoints::DOWNLOADCOVERART,
get(crate::callers::coverart::endpoint::download_coverart),
)
.route(
crate::callers::endpoints::STREAMSONG,
get(crate::callers::song::endpoint::stream_song),
@@ -2061,5 +2065,61 @@ mod tests {
let _ = super::db_mgr::drop_database(&tm_pool, &db_name).await;
}
#[tokio::test]
async fn test_download_coverart() {
let tm_pool = super::db_mgr::get_pool().await.unwrap();
let db_name = super::db_mgr::generate_db_name().await;
match super::db_mgr::create_database(&tm_pool, &db_name).await {
Ok(_) => {
println!("Success");
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
}
let pool = super::db_mgr::connect_to_db(&db_name).await.unwrap();
super::db_mgr::migrations(&pool).await;
let app = super::init::app(pool).await;
let id = test_data::coverart_id().await.unwrap();
let uri =
super::format_url_with_value(crate::callers::endpoints::DOWNLOADCOVERART, &id)
.await;
match app
.clone()
.oneshot(
axum::http::Request::builder()
.method(axum::http::Method::GET)
.uri(&uri)
.body(axum::body::Body::empty())
.unwrap(),
)
.await
{
Ok(response) => {
let e = response.into_body();
let mut data = e.into_data_stream();
while let Some(chunk) = data.next().await {
match chunk {
Ok(_data) => {}
Err(err) => {
assert!(false, "Error: {err:?}");
}
}
}
}
Err(err) => {
assert!(false, "Error: {err:?}");
}
}
let _ = super::db_mgr::drop_database(&tm_pool, &db_name).await;
}
}
}