Refactoring tests #257

Merged
phoenix merged 14 commits from refactoring_tests into main 2026-08-12 16:53:24 -04:00
Showing only changes of commit 3c482aba3a - Show all commits
+10 -41
View File
@@ -25,11 +25,6 @@ async fn main() {
mod tests {
use std::io::Write;
/*
use common_multipart_rfc7578::client::multipart::{
Body as MultipartBody, Form as MultipartForm,
};
*/
use tower::ServiceExt;
use crate::db;
@@ -451,29 +446,10 @@ mod tests {
Ok(response) => Ok(response),
Err(err) => Err(axum::http::Error::from(err)),
},
Err(err) => {
Err(err)
// Err(std::convert::Infallible::from(err))
// Err(err)
Err(err) => Err(err),
}
}
/*
let req = axum::http::Request::builder()
.method(axum::http::Method::GET)
.uri(uri)
.header(axum::http::header::CONTENT_TYPE, "application/json")
.header(
axum::http::header::AUTHORIZATION,
super::bearer_auth().await,
)
.body(axum::body::Body::empty())
.unwrap();
app.clone().oneshot(req).await
*/
}
pub enum ReqBody {
Json(serde_json::Value),
Multipart((String, String)),
@@ -493,7 +469,7 @@ mod tests {
payload.is_some(),
"Has request body and payload has data"
);
// axum::body::Body::from(payload.unwrap().to_string())
match payload {
Some(p) => match p {
ReqBody::Json(val) => axum::body::Body::from(val.to_string()),
@@ -501,12 +477,8 @@ mod tests {
let mut form = MultipartForm::default();
let _ = form.add_file(t, p);
// Create request
// let content_type = form.content_type();
content_type = form.content_type();
println!("Content: {content_type:?}");
let body = MultipartBody::from(form);
println!("Streaming");
axum::body::Body::from_stream(body)
}
},
@@ -521,11 +493,7 @@ mod tests {
match axum::http::Request::builder()
.method(method)
.uri(uri)
.header(
axum::http::header::CONTENT_TYPE,
content_type,
// "application/json; charset=utf-8",
)
.header(axum::http::header::CONTENT_TYPE, content_type)
.header(
axum::http::header::AUTHORIZATION,
super::bearer_auth().await,
@@ -1804,12 +1772,13 @@ mod tests {
match app
.clone()
.oneshot(
axum::http::Request::builder()
.method(axum::http::Method::PATCH)
.uri(crate::callers::queue::endpoints::QUEUESONGDATAWIPE)
.header(axum::http::header::CONTENT_TYPE, "application/json")
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
.body(axum::body::Body::from(payload.to_string()))
request::run_post(
Some(request::ReqBody::Json(payload)),
crate::callers::queue::endpoints::QUEUESONGDATAWIPE,
axum::http::Method::PATCH,
true,
)
.await
.unwrap(),
)
.await