This commit is contained in:
+24
-11
@@ -484,6 +484,7 @@ mod tests {
|
|||||||
method: axum::http::Method,
|
method: axum::http::Method,
|
||||||
has_body: bool,
|
has_body: bool,
|
||||||
) -> Result<axum::http::Request<axum::body::Body>, axum::http::Error> {
|
) -> Result<axum::http::Request<axum::body::Body>, axum::http::Error> {
|
||||||
|
let mut content_type = "application/json; charset=utf-8".to_string();
|
||||||
let body = if has_body {
|
let body = if has_body {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
true,
|
true,
|
||||||
@@ -491,17 +492,25 @@ mod tests {
|
|||||||
"Has request body and payload has data"
|
"Has request body and payload has data"
|
||||||
);
|
);
|
||||||
// axum::body::Body::from(payload.unwrap().to_string())
|
// axum::body::Body::from(payload.unwrap().to_string())
|
||||||
match payload.unwrap() {
|
match payload {
|
||||||
ReqBody::Json(val) => axum::body::Body::from(val.to_string()),
|
Some(p) => match p {
|
||||||
ReqBody::Multipart((t, p)) => {
|
ReqBody::Json(val) => axum::body::Body::from(val.to_string()),
|
||||||
let mut form = MultipartForm::default();
|
ReqBody::Multipart((t, p)) => {
|
||||||
let _ = form.add_file(t, p);
|
let mut form = MultipartForm::default();
|
||||||
|
let _ = form.add_file(t, p);
|
||||||
|
|
||||||
// Create request
|
// Create request
|
||||||
let content_type = form.content_type();
|
// let content_type = form.content_type();
|
||||||
println!("Content: {content_type:?}");
|
content_type = form.content_type();
|
||||||
let body = MultipartBody::from(form);
|
println!("Content: {content_type:?}");
|
||||||
axum::body::Body::from_stream(body)
|
let body = MultipartBody::from(form);
|
||||||
|
println!("Streaming");
|
||||||
|
axum::body::Body::from_stream(body)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
None => {
|
||||||
|
eprintln!("This should not empty");
|
||||||
|
axum::body::Body::empty()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -512,7 +521,8 @@ mod tests {
|
|||||||
.uri(uri)
|
.uri(uri)
|
||||||
.header(
|
.header(
|
||||||
axum::http::header::CONTENT_TYPE,
|
axum::http::header::CONTENT_TYPE,
|
||||||
"application/json; charset=utf-8",
|
content_type,
|
||||||
|
// "application/json; charset=utf-8",
|
||||||
)
|
)
|
||||||
.header(
|
.header(
|
||||||
axum::http::header::AUTHORIZATION,
|
axum::http::header::AUTHORIZATION,
|
||||||
@@ -798,8 +808,10 @@ mod tests {
|
|||||||
let app = init::app(pool).await;
|
let app = init::app(pool).await;
|
||||||
|
|
||||||
// Send request
|
// Send request
|
||||||
|
println!("Trying");
|
||||||
match request::song_queue_req(&app).await {
|
match request::song_queue_req(&app).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
|
println!("response: {response:?}");
|
||||||
let resp = util::get_resp_data::<
|
let resp = util::get_resp_data::<
|
||||||
crate::callers::queue::song::response::song_queue::Response,
|
crate::callers::queue::song::response::song_queue::Response,
|
||||||
>(response)
|
>(response)
|
||||||
@@ -808,6 +820,7 @@ mod tests {
|
|||||||
assert_eq!(false, resp.data[0].is_nil(), "Should not be empty");
|
assert_eq!(false, resp.data[0].is_nil(), "Should not be empty");
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
eprintln!("Failure!");
|
||||||
assert!(false, "Error: {:?}", err);
|
assert!(false, "Error: {:?}", err);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user