Preparing test

This commit is contained in:
kdeng00
2025-05-19 21:08:58 -04:00
parent 435e39b530
commit e07bec444b
+32 -17
View File
@@ -273,6 +273,33 @@ mod tests {
app.clone().oneshot(req).await app.clone().oneshot(req).await
} }
async fn upload_coverart_queue(
app: &axum::Router,
) -> Result<axum::response::Response, std::convert::Infallible> {
// 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( 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> {
@@ -618,25 +645,9 @@ mod tests {
db::migrations(&pool).await; db::migrations(&pool).await;
let app = init::app(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 // Send request
match app match upload_coverart_queue(&app).await
.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
{ {
Ok(response) => { Ok(response) => {
let resp = let resp =
@@ -652,4 +663,8 @@ mod tests {
let _ = db_mgr::drop_database(&tm_pool, &db_name).await; let _ = db_mgr::drop_database(&tm_pool, &db_name).await;
} }
#[tokio::test]
async fn test_song_coverart_queue_link() {
}
} }