dynamic_db #17

Merged
phoenix merged 31 commits from dynamic_db into devel 2025-04-05 01:30:36 +00:00
Showing only changes of commit 076fbad578 - Show all commits

View File

@@ -64,10 +64,16 @@ mod tests {
http::{Request, StatusCode},
};
use http_body_util::BodyExt;
// use reqwest;
use serde::{Deserialize, Serialize};
use serde_json::json;
use tower::ServiceExt; // for `call`, `oneshot`, and `ready`
#[derive(Deserialize, Serialize)]
struct Response {
pub message: String,
pub data: icarus_auth::models::common::User,
}
#[tokio::test]
async fn test_hello_world() {
let app = init::app().await;
@@ -106,8 +112,8 @@ mod tests {
};
let payload = json!({
"username": usr.username,
"password": usr.password,
"username": &usr.username,
"password": &usr.password,
});
let response = app
@@ -124,6 +130,15 @@ mod tests {
match response {
Ok(resp) => {
assert_eq!(resp.status(), StatusCode::CREATED, "Message: {:?}", resp);
let body = axum::body::to_bytes(resp.into_body(), usize::MAX)
.await
.unwrap();
let parsed_body: Response = serde_json::from_slice(&body).unwrap();
assert_eq!(
usr.username, parsed_body.data.username,
"Usernames do not match"
);
}
Err(err) => {
assert!(false, "Error: {:?}", err.to_string());