Test refactor

This commit is contained in:
kdeng00
2025-05-24 18:55:21 -04:00
parent 795f746397
commit 24666c29ff
+19 -40
View File
@@ -395,6 +395,23 @@ mod tests {
app.clone().oneshot(req).await app.clone().oneshot(req).await
} }
async fn get_queued_coverart(app: &axum::Router, coverart_queue_id: &uuid::Uuid) -> Result<axum::response::Response, std::convert::Infallible> {
let uri = format!(
"{}?id={}",
crate::callers::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")
.body(axum::body::Body::empty())
.unwrap();
app.clone().oneshot(req).await
}
pub async fn resp_to_bytes( pub async fn resp_to_bytes(
response: axum::response::Response, response: axum::response::Response,
) -> Result<axum::body::Bytes, axum::Error> { ) -> Result<axum::body::Bytes, axum::Error> {
@@ -941,26 +958,7 @@ mod tests {
"Should not be empty" "Should not be empty"
); );
let uri = format!( match get_queued_coverart(&app, &resp_coverart_id).await
"{}?id={}",
crate::callers::endpoints::QUEUECOVERART,
resp_coverart_id
);
match app
.clone()
.oneshot(
axum::http::Request::builder()
.method(axum::http::Method::GET)
.uri(uri)
.header(
axum::http::header::CONTENT_TYPE,
"application/json",
)
.body(axum::body::Body::empty())
.unwrap(),
)
.await
{ {
Ok(response) => { Ok(response) => {
let resp = get_resp_data::< let resp = get_resp_data::<
@@ -1409,26 +1407,7 @@ mod tests {
"Should not be empty" "Should not be empty"
); );
let uri = format!( match get_queued_coverart(&app, &resp_coverart_id).await
"{}?id={}",
crate::callers::endpoints::QUEUECOVERART,
resp_coverart_id
);
match app
.clone()
.oneshot(
axum::http::Request::builder()
.method(axum::http::Method::GET)
.uri(uri)
.header(
axum::http::header::CONTENT_TYPE,
"application/json",
)
.body(axum::body::Body::empty())
.unwrap(),
)
.await
{ {
Ok(response) => { Ok(response) => {
let resp = get_resp_data::< let resp = get_resp_data::<