Test change
This commit is contained in:
+26
-18
@@ -176,22 +176,11 @@ mod request {
|
|||||||
"user_id": super::TEST_USER_ID,
|
"user_id": super::TEST_USER_ID,
|
||||||
});
|
});
|
||||||
|
|
||||||
/*
|
|
||||||
let req = axum::http::Request::builder()
|
|
||||||
.method(axum::http::Method::POST)
|
|
||||||
.uri(textsender_api::caller::endpoints::ADD_CONTACT)
|
|
||||||
.header(axum::http::header::CONTENT_TYPE, "application/json")
|
|
||||||
.header(
|
|
||||||
axum::http::header::AUTHORIZATION,
|
|
||||||
super::bearer_auth().await,
|
|
||||||
)
|
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
|
||||||
.unwrap();
|
|
||||||
*/
|
|
||||||
match run_post(
|
match run_post(
|
||||||
&payload,
|
Some(&payload),
|
||||||
textsender_api::caller::endpoints::ADD_CONTACT,
|
textsender_api::caller::endpoints::ADD_CONTACT,
|
||||||
axum::http::Method::POST,
|
axum::http::Method::POST,
|
||||||
|
true,
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
@@ -206,13 +195,22 @@ mod request {
|
|||||||
pub async fn get_contact(
|
pub async fn get_contact(
|
||||||
app: &axum::Router,
|
app: &axum::Router,
|
||||||
id: &uuid::Uuid,
|
id: &uuid::Uuid,
|
||||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
) -> Result<axum::response::Response, axum::http::Error> {
|
||||||
let uri = format!(
|
let uri = format!(
|
||||||
"{}?id={}",
|
"{}?id={}",
|
||||||
textsender_api::caller::endpoints::GET_CONTACT,
|
textsender_api::caller::endpoints::GET_CONTACT,
|
||||||
id
|
id
|
||||||
);
|
);
|
||||||
|
|
||||||
|
match run_post(None, &uri, axum::http::Method::GET, false).await {
|
||||||
|
Ok(req) => match app.clone().oneshot(req).await {
|
||||||
|
Ok(response) => Ok(response),
|
||||||
|
Err(err) => Err(axum::http::Error::from(err)),
|
||||||
|
},
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
let req = axum::http::Request::builder()
|
let req = axum::http::Request::builder()
|
||||||
.method(axum::http::Method::GET)
|
.method(axum::http::Method::GET)
|
||||||
.uri(uri)
|
.uri(uri)
|
||||||
@@ -225,6 +223,7 @@ mod request {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
app.clone().oneshot(req).await
|
app.clone().oneshot(req).await
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn update_contact_names(
|
pub async fn update_contact_names(
|
||||||
@@ -305,12 +304,21 @@ mod request {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
pub async fn run_post(
|
pub async fn run_post(
|
||||||
payload: &serde_json::Value,
|
payload: Option<&serde_json::Value>,
|
||||||
uri: &str,
|
uri: &str,
|
||||||
method: axum::http::Method,
|
method: axum::http::Method,
|
||||||
|
has_body: bool,
|
||||||
) -> Result<axum::http::Request<axum::body::Body>, axum::http::Error> {
|
) -> Result<axum::http::Request<axum::body::Body>, axum::http::Error> {
|
||||||
// textsender_api::caller::endpoints::ADD_MESSAGE)
|
let body = if has_body {
|
||||||
//axum::http::Method::POST)
|
assert_eq!(
|
||||||
|
true,
|
||||||
|
payload.is_some(),
|
||||||
|
"Has request body and payload has data"
|
||||||
|
);
|
||||||
|
axum::body::Body::from(payload.unwrap().to_string())
|
||||||
|
} else {
|
||||||
|
axum::body::Body::empty()
|
||||||
|
};
|
||||||
match axum::http::Request::builder()
|
match axum::http::Request::builder()
|
||||||
.method(method)
|
.method(method)
|
||||||
.uri(uri)
|
.uri(uri)
|
||||||
@@ -319,7 +327,7 @@ mod request {
|
|||||||
axum::http::header::AUTHORIZATION,
|
axum::http::header::AUTHORIZATION,
|
||||||
super::bearer_auth().await,
|
super::bearer_auth().await,
|
||||||
)
|
)
|
||||||
.body(axum::body::Body::from(payload.to_string()))
|
.body(body)
|
||||||
{
|
{
|
||||||
Ok(t) => Ok(t),
|
Ok(t) => Ok(t),
|
||||||
Err(err) => Err(err),
|
Err(err) => Err(err),
|
||||||
|
|||||||
Reference in New Issue
Block a user