From e07bec444b254c94da3694139f5e6abfd1fd0fee Mon Sep 17 00:00:00 2001 From: kdeng00 Date: Mon, 19 May 2025 21:08:58 -0400 Subject: [PATCH] Preparing test --- src/main.rs | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/src/main.rs b/src/main.rs index 74a9000..15d2698 100644 --- a/src/main.rs +++ b/src/main.rs @@ -273,6 +273,33 @@ mod tests { app.clone().oneshot(req).await } + async fn upload_coverart_queue( + app: &axum::Router, + ) -> Result { + // let app = init::app(pool).await; + let mut form = MultipartForm::default(); + let _ = form.add_file("jpg", "tests/Machine_gun/160809_machinegun.jpg"); + + // Create request + let content_type = form.content_type(); + let body = MultipartBody::from(form); + + let req = axum::http::Request::builder() + .method(axum::http::Method::POST) + .uri(crate::callers::endpoints::QUEUECOVERART) + .header(axum::http::header::CONTENT_TYPE, content_type) + .body(axum::body::Body::from_stream(body)) + .unwrap(); + + // Send request + app + .clone() + .oneshot( + req + ) + .await + } + pub async fn resp_to_bytes( response: axum::response::Response, ) -> Result { @@ -618,25 +645,9 @@ mod tests { db::migrations(&pool).await; let app = init::app(pool).await; - let mut form = MultipartForm::default(); - let _ = form.add_file("jpg", "tests/Machine_gun/160809_machinegun.jpg"); - - // Create request - let content_type = form.content_type(); - let body = MultipartBody::from(form); // Send request - match app - .clone() - .oneshot( - axum::http::Request::builder() - .method(axum::http::Method::POST) - .uri(crate::callers::endpoints::QUEUECOVERART) - .header(axum::http::header::CONTENT_TYPE, content_type) - .body(axum::body::Body::from_stream(body)) - .unwrap(), - ) - .await + match upload_coverart_queue(&app).await { Ok(response) => { let resp = @@ -652,4 +663,8 @@ mod tests { let _ = db_mgr::drop_database(&tm_pool, &db_name).await; } + + #[tokio::test] + async fn test_song_coverart_queue_link() { + } }