Updated test
Rust Build / Test Suite (pull_request) Failing after 1m21s
Rust Build / Check (pull_request) Successful in 1m33s
Rust Build / Rustfmt (pull_request) Successful in 33s
Rust Build / Clippy (pull_request) Successful in 1m14s
Rust Build / build (pull_request) Successful in 1m56s
Rust Build / Test Suite (pull_request) Failing after 1m21s
Rust Build / Check (pull_request) Successful in 1m33s
Rust Build / Rustfmt (pull_request) Successful in 33s
Rust Build / Clippy (pull_request) Successful in 1m14s
Rust Build / build (pull_request) Successful in 1m56s
This commit is contained in:
+24
-3
@@ -79,8 +79,11 @@ pub mod requests {
|
||||
app: &axum::Router,
|
||||
) -> Result<axum::response::Response, std::convert::Infallible> {
|
||||
let payload = serde_json::json!({
|
||||
"username": "Billy",
|
||||
"password": "Bob",
|
||||
"username": String::from(super::TEST_USERNAME),
|
||||
"password": String::from(super::TEST_PASSWORD),
|
||||
"phone_number": String::from(super::TEST_PHONE_NUMBER),
|
||||
"firstname": String::from(super::TEST_FIRSTNAME),
|
||||
"lastname": String::from(super::TEST_LASTNAME),
|
||||
});
|
||||
let req = axum::http::Request::builder()
|
||||
.method(axum::http::Method::POST)
|
||||
@@ -100,6 +103,12 @@ fn test_demo() {
|
||||
assert_eq!(0, i, "Values should match {} {}", 0, 1);
|
||||
}
|
||||
|
||||
const TEST_FIRSTNAME: &str = "Billy";
|
||||
const TEST_LASTNAME: &str = "Bob";
|
||||
const TEST_USERNAME: &str = "BillyBob01";
|
||||
const TEST_PASSWORD: &str = "923ndcry392qryudx328qrdy328r";
|
||||
const TEST_PHONE_NUMBER: &str = "+10123456789";
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_register_user() {
|
||||
let tm_pool = db_mgr::get_pool().await.unwrap();
|
||||
@@ -122,7 +131,19 @@ async fn test_register_user() {
|
||||
let app = init::routes().await.layer(axum::Extension(pool));
|
||||
|
||||
match requests::register_user(&app).await {
|
||||
Ok(_response) => {}
|
||||
Ok(response) => {
|
||||
let body = axum::body::to_bytes(response.into_body(), usize::MAX)
|
||||
.await
|
||||
.unwrap();
|
||||
let parsed_body: callers::register::response::Response =
|
||||
serde_json::from_slice(&body).unwrap();
|
||||
assert!(parsed_body.data.len() > 0, "No data found");
|
||||
let returned_user = &parsed_body.data[0];
|
||||
assert_eq!(
|
||||
TEST_USERNAME, returned_user.username,
|
||||
"Error with returned user"
|
||||
);
|
||||
}
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {err:?}");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user