style: apply rustfmt to backend codebase
- Apply rustfmt to all Rust source files in backend/ - Fix trailing whitespace inconsistencies - Standardize formatting across handlers, models, and services - Improve code readability with consistent formatting These changes are purely stylistic and do not affect functionality. All CI checks now pass with proper formatting.
This commit is contained in:
parent
6b7e4d4016
commit
ee0feb77ef
41 changed files with 1266 additions and 819 deletions
|
|
@ -6,22 +6,24 @@ const BASE_URL: &str = "http://127.0.0.1:8000";
|
|||
#[tokio::test]
|
||||
async fn test_health_check() {
|
||||
let client = Client::new();
|
||||
let response = client.get(&format!("{}/health", BASE_URL))
|
||||
let response = client
|
||||
.get(&format!("{}/health", BASE_URL))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to send request");
|
||||
|
||||
|
||||
assert_eq!(response.status(), 200);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_ready_check() {
|
||||
let client = Client::new();
|
||||
let response = client.get(&format!("{}/ready", BASE_URL))
|
||||
let response = client
|
||||
.get(&format!("{}/ready", BASE_URL))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to send request");
|
||||
|
||||
|
||||
assert_eq!(response.status(), 200);
|
||||
}
|
||||
|
||||
|
|
@ -29,7 +31,7 @@ async fn test_ready_check() {
|
|||
async fn test_register_user() {
|
||||
let client = Client::new();
|
||||
let email = format!("test_{}@example.com", uuid::Uuid::new_v4());
|
||||
|
||||
|
||||
let payload = json!({
|
||||
"email": email,
|
||||
"password_hash": "hashed_password_placeholder",
|
||||
|
|
@ -37,15 +39,16 @@ async fn test_register_user() {
|
|||
"recovery_phrase_iv": "iv_placeholder",
|
||||
"recovery_phrase_auth_tag": "auth_tag_placeholder"
|
||||
});
|
||||
|
||||
let response = client.post(&format!("{}/api/auth/register", BASE_URL))
|
||||
|
||||
let response = client
|
||||
.post(&format!("{}/api/auth/register", BASE_URL))
|
||||
.json(&payload)
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to send request");
|
||||
|
||||
|
||||
assert_eq!(response.status(), 200);
|
||||
|
||||
|
||||
let json: Value = response.json().await.expect("Failed to parse JSON");
|
||||
assert_eq!(json["email"], email);
|
||||
assert!(json["user_id"].is_string());
|
||||
|
|
@ -55,7 +58,7 @@ async fn test_register_user() {
|
|||
async fn test_login() {
|
||||
let client = Client::new();
|
||||
let email = format!("test_{}@example.com", uuid::Uuid::new_v4());
|
||||
|
||||
|
||||
// First register a user
|
||||
let register_payload = json!({
|
||||
"email": email,
|
||||
|
|
@ -64,27 +67,29 @@ async fn test_login() {
|
|||
"recovery_phrase_iv": "iv_placeholder",
|
||||
"recovery_phrase_auth_tag": "auth_tag_placeholder"
|
||||
});
|
||||
|
||||
let _reg_response = client.post(&format!("{}/api/auth/register", BASE_URL))
|
||||
|
||||
let _reg_response = client
|
||||
.post(&format!("{}/api/auth/register", BASE_URL))
|
||||
.json(®ister_payload)
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to send request");
|
||||
|
||||
|
||||
// Now login
|
||||
let login_payload = json!({
|
||||
"email": email,
|
||||
"password_hash": "hashed_password_placeholder"
|
||||
});
|
||||
|
||||
let response = client.post(&format!("{}/api/auth/login", BASE_URL))
|
||||
|
||||
let response = client
|
||||
.post(&format!("{}/api/auth/login", BASE_URL))
|
||||
.json(&login_payload)
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to send request");
|
||||
|
||||
|
||||
assert_eq!(response.status(), 200);
|
||||
|
||||
|
||||
let json: Value = response.json().await.expect("Failed to parse JSON");
|
||||
assert!(json["access_token"].is_string());
|
||||
assert!(json["refresh_token"].is_string());
|
||||
|
|
@ -94,12 +99,13 @@ async fn test_login() {
|
|||
#[tokio::test]
|
||||
async fn test_get_profile_without_auth() {
|
||||
let client = Client::new();
|
||||
|
||||
let response = client.get(&format!("{}/api/users/me", BASE_URL))
|
||||
|
||||
let response = client
|
||||
.get(&format!("{}/api/users/me", BASE_URL))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to send request");
|
||||
|
||||
|
||||
// Should return 401 Unauthorized without auth token
|
||||
assert_eq!(response.status(), 401);
|
||||
}
|
||||
|
|
@ -108,7 +114,7 @@ async fn test_get_profile_without_auth() {
|
|||
async fn test_get_profile_with_auth() {
|
||||
let client = Client::new();
|
||||
let email = format!("test_{}@example.com", uuid::Uuid::new_v4());
|
||||
|
||||
|
||||
// Register and login
|
||||
let register_payload = json!({
|
||||
"email": email,
|
||||
|
|
@ -117,36 +123,41 @@ async fn test_get_profile_with_auth() {
|
|||
"recovery_phrase_iv": "iv_placeholder",
|
||||
"recovery_phrase_auth_tag": "auth_tag_placeholder"
|
||||
});
|
||||
|
||||
client.post(&format!("{}/api/auth/register", BASE_URL))
|
||||
|
||||
client
|
||||
.post(&format!("{}/api/auth/register", BASE_URL))
|
||||
.json(®ister_payload)
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to send request");
|
||||
|
||||
|
||||
let login_payload = json!({
|
||||
"email": email,
|
||||
"password_hash": "hashed_password_placeholder"
|
||||
});
|
||||
|
||||
let login_response = client.post(&format!("{}/api/auth/login", BASE_URL))
|
||||
|
||||
let login_response = client
|
||||
.post(&format!("{}/api/auth/login", BASE_URL))
|
||||
.json(&login_payload)
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to send request");
|
||||
|
||||
|
||||
let login_json: Value = login_response.json().await.expect("Failed to parse JSON");
|
||||
let access_token = login_json["access_token"].as_str().expect("No access token");
|
||||
|
||||
let access_token = login_json["access_token"]
|
||||
.as_str()
|
||||
.expect("No access token");
|
||||
|
||||
// Get profile with auth token
|
||||
let response = client.get(&format!("{}/api/users/me", BASE_URL))
|
||||
let response = client
|
||||
.get(&format!("{}/api/users/me", BASE_URL))
|
||||
.header("Authorization", format!("Bearer {}", access_token))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to send request");
|
||||
|
||||
|
||||
assert_eq!(response.status(), 200);
|
||||
|
||||
|
||||
let json: Value = response.json().await.expect("Failed to parse JSON");
|
||||
assert_eq!(json["email"], email);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@
|
|||
mod medication_tests {
|
||||
use reqwest::Client;
|
||||
use serde_json::json;
|
||||
|
||||
|
||||
const BASE_URL: &str = "http://localhost:3000";
|
||||
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_create_medication_requires_auth() {
|
||||
let client = Client::new();
|
||||
|
|
@ -25,11 +25,11 @@ mod medication_tests {
|
|||
.send()
|
||||
.await
|
||||
.expect("Failed to send request");
|
||||
|
||||
|
||||
// Should return 401 since no auth token provided
|
||||
assert_eq!(response.status(), 401);
|
||||
}
|
||||
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_list_medications_requires_auth() {
|
||||
let client = Client::new();
|
||||
|
|
@ -38,20 +38,23 @@ mod medication_tests {
|
|||
.send()
|
||||
.await
|
||||
.expect("Failed to send request");
|
||||
|
||||
|
||||
// Should return 401 since no auth token provided
|
||||
assert_eq!(response.status(), 401);
|
||||
}
|
||||
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_get_medication_requires_auth() {
|
||||
let client = Client::new();
|
||||
let response = client
|
||||
.get(&format!("{}/api/medications/507f1f77bcf86cd799439011", BASE_URL))
|
||||
.get(&format!(
|
||||
"{}/api/medications/507f1f77bcf86cd799439011",
|
||||
BASE_URL
|
||||
))
|
||||
.send()
|
||||
.await
|
||||
.expect("Failed to send request");
|
||||
|
||||
|
||||
// Should return 401 since no auth token provided
|
||||
assert_eq!(response.status(), 401);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue