I'm writing a unit test for a server being built with Axum, using the official example
...
// the response
let response = app
.oneshot(
Request::builder()
.method(http::Method::POST)
.uri("/v1/auth/sign-up")
.header(http::header::CONTENT_TYPE, mime::APPLICATION_JSON.as_ref())
.body(Body::from(
serde_json::to_vec(&json!({
"id":user_id,
"firstname":firstname,
"lastname":lastname,
"middlename":middlename,
"username":username,
"fullname":format!("{firstname} {middlename} {lastname}", ),
"email":format!("{firstname}@mailer.com"),
"password":password,
"avatar":format!("{avatar}.jpg"),
"gender":"Female",
"dateOfBirth":"2002-06-09",
"phoneNumber":phone_number
}))
.unwrap(),
))
.unwrap(),
)
.await
.unwrap();
println!("hey {:?}", response.body());
the response body returns an instance of UnsynBoxBody
, I'm stuck trying to get the content from the UnsyncBoxBody instance. and my test keeps failing with a 500 error even thought the endpoint works fine.