fix(tests): resolve weird compilation issue in the tests
This commit is contained in:
parent
0e3418a35a
commit
67f399c6c4
|
|
@ -19,7 +19,7 @@ use std::time::{Duration, Instant};
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use readur::models::{CreateUser, LoginRequest, LoginResponse, UserRole};
|
use readur::models::{CreateUser, LoginRequest, LoginResponse, UserRole, DocumentResponse};
|
||||||
use readur::routes::documents::types::DocumentUploadResponse;
|
use readur::routes::documents::types::DocumentUploadResponse;
|
||||||
|
|
||||||
fn get_base_url() -> String {
|
fn get_base_url() -> String {
|
||||||
|
|
@ -376,8 +376,7 @@ End of test document."#;
|
||||||
// Validate initial document properties
|
// Validate initial document properties
|
||||||
assert_eq!(document.mime_type, "text/plain");
|
assert_eq!(document.mime_type, "text/plain");
|
||||||
assert!(document.file_size > 0);
|
assert!(document.file_size > 0);
|
||||||
assert_eq!(document.original_filename, "test_pipeline.txt");
|
assert_eq!(document.filename, "test_pipeline.txt");
|
||||||
assert!(document.ocr_status.is_some());
|
|
||||||
|
|
||||||
// Wait for processing to complete
|
// Wait for processing to complete
|
||||||
let processed_doc = client.wait_for_processing(&document_id).await
|
let processed_doc = client.wait_for_processing(&document_id).await
|
||||||
|
|
@ -475,7 +474,7 @@ async fn test_multiple_file_format_support() {
|
||||||
|
|
||||||
match client.upload_file(content, filename, mime_type).await {
|
match client.upload_file(content, filename, mime_type).await {
|
||||||
Ok(document) => {
|
Ok(document) => {
|
||||||
println!("✅ Uploaded {}: {}", filename, document.id);
|
println!("✅ Uploaded {}: {}", filename, document.document_id);
|
||||||
uploaded_documents.push((document, mime_type, filename, content));
|
uploaded_documents.push((document, mime_type, filename, content));
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
|
@ -491,7 +490,7 @@ async fn test_multiple_file_format_support() {
|
||||||
for (document, mime_type, filename, original_content) in &uploaded_documents {
|
for (document, mime_type, filename, original_content) in &uploaded_documents {
|
||||||
println!("🔄 Processing {} ({})...", filename, mime_type);
|
println!("🔄 Processing {} ({})...", filename, mime_type);
|
||||||
|
|
||||||
let document_id = document.id.to_string();
|
let document_id = document.document_id.to_string();
|
||||||
|
|
||||||
// Wait for processing (with shorter timeout for multiple files)
|
// Wait for processing (with shorter timeout for multiple files)
|
||||||
match client.wait_for_processing(&document_id).await {
|
match client.wait_for_processing(&document_id).await {
|
||||||
|
|
@ -558,13 +557,13 @@ async fn test_image_processing_pipeline() {
|
||||||
let document = client.upload_binary_file(png_data.clone(), "test_image.png", "image/png").await
|
let document = client.upload_binary_file(png_data.clone(), "test_image.png", "image/png").await
|
||||||
.expect("Failed to upload PNG image");
|
.expect("Failed to upload PNG image");
|
||||||
|
|
||||||
let document_id = document.id.to_string();
|
let document_id = document.document_id.to_string();
|
||||||
println!("✅ PNG image uploaded: {}", document_id);
|
println!("✅ PNG image uploaded: {}", document_id);
|
||||||
|
|
||||||
// Validate image document properties
|
// Validate image document properties
|
||||||
assert_eq!(document.mime_type, "image/png");
|
assert_eq!(document.mime_type, "image/png");
|
||||||
assert!(document.file_size > 0);
|
assert!(document.file_size > 0);
|
||||||
assert_eq!(document.original_filename, "test_image.png");
|
assert_eq!(document.filename, "test_image.png");
|
||||||
|
|
||||||
// Wait for processing - note that minimal images might fail OCR
|
// Wait for processing - note that minimal images might fail OCR
|
||||||
let processed_result = client.wait_for_processing(&document_id).await;
|
let processed_result = client.wait_for_processing(&document_id).await;
|
||||||
|
|
@ -689,7 +688,7 @@ async fn test_processing_error_recovery() {
|
||||||
|
|
||||||
match large_result {
|
match large_result {
|
||||||
Ok(document) => {
|
Ok(document) => {
|
||||||
println!("✅ Large file uploaded: {} (size: {} bytes)", document.id, document.file_size);
|
println!("✅ Large file uploaded: {} (size: {} bytes)", document.document_id, document.file_size);
|
||||||
|
|
||||||
// Give more time for large file processing
|
// Give more time for large file processing
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
|
@ -707,7 +706,7 @@ async fn test_processing_error_recovery() {
|
||||||
if let Ok(docs) = serde_json::from_value::<Vec<DocumentResponse>>(
|
if let Ok(docs) = serde_json::from_value::<Vec<DocumentResponse>>(
|
||||||
response_json["documents"].clone()
|
response_json["documents"].clone()
|
||||||
) {
|
) {
|
||||||
if let Some(doc) = docs.iter().find(|d| d.id == document.id) {
|
if let Some(doc) = docs.iter().find(|d| d.id.to_string() == document.document_id.to_string()) {
|
||||||
match doc.ocr_status.as_deref() {
|
match doc.ocr_status.as_deref() {
|
||||||
Some("completed") => {
|
Some("completed") => {
|
||||||
println!("✅ Large file processing completed");
|
println!("✅ Large file processing completed");
|
||||||
|
|
@ -769,7 +768,7 @@ async fn test_processing_error_recovery() {
|
||||||
match special_result {
|
match special_result {
|
||||||
Ok(document) => {
|
Ok(document) => {
|
||||||
println!("✅ File with special characters uploaded: {}", document.document_id);
|
println!("✅ File with special characters uploaded: {}", document.document_id);
|
||||||
println!("✅ Original filename preserved: {}", document.original_filename);
|
println!("✅ Filename preserved: {}", document.filename);
|
||||||
|
|
||||||
match client.wait_for_processing(&document.document_id.to_string()).await {
|
match client.wait_for_processing(&document.document_id.to_string()).await {
|
||||||
Ok(_) => println!("✅ Special filename file processed successfully"),
|
Ok(_) => println!("✅ Special filename file processed successfully"),
|
||||||
|
|
@ -983,7 +982,7 @@ async fn test_concurrent_file_processing() {
|
||||||
for document in uploaded_documents {
|
for document in uploaded_documents {
|
||||||
let token = client.token.clone().unwrap();
|
let token = client.token.clone().unwrap();
|
||||||
let client_clone = client.client.clone();
|
let client_clone = client.client.clone();
|
||||||
let document_id = document.id.to_string();
|
let document_id = document.document_id.to_string();
|
||||||
|
|
||||||
let handle = tokio::spawn(async move {
|
let handle = tokio::spawn(async move {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
|
@ -1150,7 +1149,7 @@ async fn test_real_test_images_processing() {
|
||||||
test_image.filename, processing_time, processed_doc.ocr_status);
|
test_image.filename, processing_time, processed_doc.ocr_status);
|
||||||
|
|
||||||
// Get OCR results and verify content
|
// Get OCR results and verify content
|
||||||
if let Ok(ocr_results) = client.get_ocr_results(&document.id.to_string()).await {
|
if let Ok(ocr_results) = client.get_ocr_results(&document.document_id.to_string()).await {
|
||||||
if let Some(ocr_text) = ocr_results["ocr_text"].as_str() {
|
if let Some(ocr_text) = ocr_results["ocr_text"].as_str() {
|
||||||
let normalized_ocr = ocr_text.trim().to_lowercase();
|
let normalized_ocr = ocr_text.trim().to_lowercase();
|
||||||
let normalized_expected = test_image.expected_content.as_ref().map(|s| s.trim().to_lowercase()).unwrap_or_default();
|
let normalized_expected = test_image.expected_content.as_ref().map(|s| s.trim().to_lowercase()).unwrap_or_default();
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ use serde_json::{json, Value};
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
|
|
||||||
use readur::models::{CreateUser, LoginRequest, LoginResponse};
|
use readur::models::{CreateUser, LoginRequest, LoginResponse, DocumentResponse};
|
||||||
use readur::routes::documents::types::DocumentUploadResponse;
|
use readur::routes::documents::types::DocumentUploadResponse;
|
||||||
|
|
||||||
fn get_base_url() -> String {
|
fn get_base_url() -> String {
|
||||||
|
|
@ -217,24 +217,22 @@ Technology: Rust + Axum + SQLx"#;
|
||||||
|
|
||||||
// Validate document response structure using our types
|
// Validate document response structure using our types
|
||||||
assert!(!document.filename.is_empty());
|
assert!(!document.filename.is_empty());
|
||||||
assert!(!document.original_filename.is_empty());
|
|
||||||
assert!(document.file_size > 0);
|
assert!(document.file_size > 0);
|
||||||
assert_eq!(document.mime_type, "text/plain");
|
assert_eq!(document.mime_type, "text/plain");
|
||||||
assert!(document.ocr_status.is_some());
|
|
||||||
|
|
||||||
// Wait for OCR processing
|
// Wait for OCR processing
|
||||||
let ocr_completed = client.wait_for_ocr_completion(&document.id.to_string()).await
|
let ocr_completed = client.wait_for_ocr_completion(&document.document_id.to_string()).await
|
||||||
.expect("Failed to wait for OCR completion");
|
.expect("Failed to wait for OCR completion");
|
||||||
|
|
||||||
assert!(ocr_completed, "OCR processing did not complete within timeout");
|
assert!(ocr_completed, "OCR processing did not complete within timeout");
|
||||||
println!("✅ OCR processing completed");
|
println!("✅ OCR processing completed");
|
||||||
|
|
||||||
// Retrieve OCR text
|
// Retrieve OCR text
|
||||||
let ocr_data = client.get_ocr_text(&document.id.to_string()).await
|
let ocr_data = client.get_ocr_text(&document.document_id.to_string()).await
|
||||||
.expect("Failed to retrieve OCR text");
|
.expect("Failed to retrieve OCR text");
|
||||||
|
|
||||||
// Validate OCR response structure
|
// Validate OCR response structure
|
||||||
assert_eq!(ocr_data["document_id"], document.id.to_string());
|
assert_eq!(ocr_data["document_id"], document.document_id.to_string());
|
||||||
assert_eq!(ocr_data["filename"], document.filename);
|
assert_eq!(ocr_data["filename"], document.filename);
|
||||||
assert!(ocr_data["has_ocr_text"].as_bool().unwrap_or(false));
|
assert!(ocr_data["has_ocr_text"].as_bool().unwrap_or(false));
|
||||||
|
|
||||||
|
|
@ -353,7 +351,7 @@ async fn test_document_list_structure() {
|
||||||
.expect("Failed to parse documents as DocumentResponse");
|
.expect("Failed to parse documents as DocumentResponse");
|
||||||
|
|
||||||
// Find our uploaded document
|
// Find our uploaded document
|
||||||
let found_doc = documents.iter().find(|d| d.id == document.id)
|
let found_doc = documents.iter().find(|d| d.id.to_string() == document.document_id.to_string())
|
||||||
.expect("Uploaded document should be in list");
|
.expect("Uploaded document should be in list");
|
||||||
|
|
||||||
// Validate structure matches our types
|
// Validate structure matches our types
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ use std::time::{Duration, Instant};
|
||||||
use tokio::time::sleep;
|
use tokio::time::sleep;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use readur::models::{CreateUser, LoginRequest, LoginResponse, UserRole};
|
use readur::models::{CreateUser, LoginRequest, LoginResponse, UserRole, DocumentResponse};
|
||||||
use readur::routes::documents::types::DocumentUploadResponse;
|
use readur::routes::documents::types::DocumentUploadResponse;
|
||||||
|
|
||||||
fn get_base_url() -> String {
|
fn get_base_url() -> String {
|
||||||
|
|
@ -432,7 +432,7 @@ async fn test_concurrent_ocr_processing() {
|
||||||
|
|
||||||
// Collect document IDs
|
// Collect document IDs
|
||||||
let document_ids: Vec<String> = documents.iter()
|
let document_ids: Vec<String> = documents.iter()
|
||||||
.map(|d| d.id.to_string())
|
.map(|d| d.document_id.to_string())
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
// Monitor queue stats during processing
|
// Monitor queue stats during processing
|
||||||
|
|
|
||||||
|
|
@ -494,7 +494,7 @@ async fn test_search_performance_with_load() {
|
||||||
|
|
||||||
match client.timed_upload(&content, &filename).await {
|
match client.timed_upload(&content, &filename).await {
|
||||||
Ok((document, _)) => {
|
Ok((document, _)) => {
|
||||||
document_ids.push(document.id.to_string());
|
document_ids.push(document.document_id.to_string());
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("⚠️ Failed to upload document {}: {}", i, e);
|
println!("⚠️ Failed to upload document {}: {}", i, e);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue