Unit test in Axum 0.5.16

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.

If the endpoint is responding with a 500 status code, your problem isn't getting the data out of the body, you must be missing something in your request

I'll check that again

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.