+11
-42
@@ -25,11 +25,6 @@ async fn main() {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use std::io::Write;
|
use std::io::Write;
|
||||||
|
|
||||||
/*
|
|
||||||
use common_multipart_rfc7578::client::multipart::{
|
|
||||||
Body as MultipartBody, Form as MultipartForm,
|
|
||||||
};
|
|
||||||
*/
|
|
||||||
use tower::ServiceExt;
|
use tower::ServiceExt;
|
||||||
|
|
||||||
use crate::db;
|
use crate::db;
|
||||||
@@ -451,27 +446,8 @@ mod tests {
|
|||||||
Ok(response) => Ok(response),
|
Ok(response) => Ok(response),
|
||||||
Err(err) => Err(axum::http::Error::from(err)),
|
Err(err) => Err(axum::http::Error::from(err)),
|
||||||
},
|
},
|
||||||
Err(err) => {
|
Err(err) => Err(err),
|
||||||
Err(err)
|
|
||||||
// Err(std::convert::Infallible::from(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 {
|
pub enum ReqBody {
|
||||||
@@ -493,7 +469,7 @@ mod tests {
|
|||||||
payload.is_some(),
|
payload.is_some(),
|
||||||
"Has request body and payload has data"
|
"Has request body and payload has data"
|
||||||
);
|
);
|
||||||
// axum::body::Body::from(payload.unwrap().to_string())
|
|
||||||
match payload {
|
match payload {
|
||||||
Some(p) => match p {
|
Some(p) => match p {
|
||||||
ReqBody::Json(val) => axum::body::Body::from(val.to_string()),
|
ReqBody::Json(val) => axum::body::Body::from(val.to_string()),
|
||||||
@@ -501,12 +477,8 @@ mod tests {
|
|||||||
let mut form = MultipartForm::default();
|
let mut form = MultipartForm::default();
|
||||||
let _ = form.add_file(t, p);
|
let _ = form.add_file(t, p);
|
||||||
|
|
||||||
// Create request
|
|
||||||
// let content_type = form.content_type();
|
|
||||||
content_type = form.content_type();
|
content_type = form.content_type();
|
||||||
println!("Content: {content_type:?}");
|
|
||||||
let body = MultipartBody::from(form);
|
let body = MultipartBody::from(form);
|
||||||
println!("Streaming");
|
|
||||||
axum::body::Body::from_stream(body)
|
axum::body::Body::from_stream(body)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -521,11 +493,7 @@ mod tests {
|
|||||||
match axum::http::Request::builder()
|
match axum::http::Request::builder()
|
||||||
.method(method)
|
.method(method)
|
||||||
.uri(uri)
|
.uri(uri)
|
||||||
.header(
|
.header(axum::http::header::CONTENT_TYPE, content_type)
|
||||||
axum::http::header::CONTENT_TYPE,
|
|
||||||
content_type,
|
|
||||||
// "application/json; charset=utf-8",
|
|
||||||
)
|
|
||||||
.header(
|
.header(
|
||||||
axum::http::header::AUTHORIZATION,
|
axum::http::header::AUTHORIZATION,
|
||||||
super::bearer_auth().await,
|
super::bearer_auth().await,
|
||||||
@@ -1804,13 +1772,14 @@ mod tests {
|
|||||||
match app
|
match app
|
||||||
.clone()
|
.clone()
|
||||||
.oneshot(
|
.oneshot(
|
||||||
axum::http::Request::builder()
|
request::run_post(
|
||||||
.method(axum::http::Method::PATCH)
|
Some(request::ReqBody::Json(payload)),
|
||||||
.uri(crate::callers::queue::endpoints::QUEUESONGDATAWIPE)
|
crate::callers::queue::endpoints::QUEUESONGDATAWIPE,
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
axum::http::Method::PATCH,
|
||||||
.header(axum::http::header::AUTHORIZATION, bearer_auth().await)
|
true,
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
)
|
||||||
.unwrap(),
|
.await
|
||||||
|
.unwrap(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user