From 72ad31453f40f8895a48b441a04a83fb18774c64 Mon Sep 17 00:00:00 2001 From: perf3ct Date: Tue, 8 Jul 2025 00:03:30 +0000 Subject: [PATCH] debug(tests): add some debug lines to see why CI is upset --- src/test_utils.rs | 54 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/src/test_utils.rs b/src/test_utils.rs index d7d0ab9..a8a2551 100644 --- a/src/test_utils.rs +++ b/src/test_utils.rs @@ -340,7 +340,32 @@ impl TestAuthHelper { }); let response = self.make_request("POST", "/api/auth/register", Some(user_data), None).await; - let user_response: UserResponse = serde_json::from_slice(&response).unwrap(); + + // Debug logging to understand CI vs local differences + let response_str = String::from_utf8_lossy(&response); + println!("DEBUG: Register response body: {}", response_str); + println!("DEBUG: Register response length: {} bytes", response.len()); + + // Try to parse as JSON first to see what we actually got + let user_response = match serde_json::from_slice::(&response) { + Ok(json_value) => { + println!("DEBUG: Parsed JSON structure: {:#}", json_value); + // Now try to parse as UserResponse + match serde_json::from_value::(json_value) { + Ok(user_response) => user_response, + Err(e) => { + eprintln!("ERROR: Failed to parse UserResponse from JSON: {}", e); + eprintln!("ERROR: Expected fields: id (UUID), username (String), email (String), role (UserRole)"); + panic!("Failed to parse UserResponse: {}", e); + } + } + }, + Err(e) => { + eprintln!("ERROR: Response is not valid JSON: {}", e); + eprintln!("ERROR: Raw response: {:?}", response); + panic!("Invalid JSON response from register endpoint: {}", e); + } + }; TestUser { user_response, @@ -370,7 +395,32 @@ impl TestAuthHelper { }); let response = self.make_request("POST", "/api/auth/register", Some(admin_data), None).await; - let user_response: UserResponse = serde_json::from_slice(&response).unwrap(); + + // Debug logging to understand CI vs local differences + let response_str = String::from_utf8_lossy(&response); + println!("DEBUG: Admin register response body: {}", response_str); + println!("DEBUG: Admin register response length: {} bytes", response.len()); + + // Try to parse as JSON first to see what we actually got + let user_response = match serde_json::from_slice::(&response) { + Ok(json_value) => { + println!("DEBUG: Admin parsed JSON structure: {:#}", json_value); + // Now try to parse as UserResponse + match serde_json::from_value::(json_value) { + Ok(user_response) => user_response, + Err(e) => { + eprintln!("ERROR: Failed to parse admin UserResponse from JSON: {}", e); + eprintln!("ERROR: Expected fields: id (UUID), username (String), email (String), role (UserRole)"); + panic!("Failed to parse admin UserResponse: {}", e); + } + } + }, + Err(e) => { + eprintln!("ERROR: Admin response is not valid JSON: {}", e); + eprintln!("ERROR: Raw admin response: {:?}", response); + panic!("Invalid JSON response from admin register endpoint: {}", e); + } + }; TestUser { user_response,