feat(tests): fix ocr_retry issues in tests

This commit is contained in:
perf3ct 2025-07-02 21:30:36 +00:00
parent 86904205ed
commit dec4551fbd
No known key found for this signature in database
GPG Key ID: 569C4EEC436F5232
3 changed files with 27 additions and 4 deletions

View File

@ -0,0 +1,9 @@
-- Add OCR retry tracking fields to documents table
-- These fields were added to the Document struct but missing from the database schema
ALTER TABLE documents ADD COLUMN IF NOT EXISTS ocr_retry_count INTEGER DEFAULT 0;
ALTER TABLE documents ADD COLUMN IF NOT EXISTS ocr_failure_reason TEXT DEFAULT NULL;
-- Add helpful comments
COMMENT ON COLUMN documents.ocr_retry_count IS 'Number of times OCR processing has been retried for this document';
COMMENT ON COLUMN documents.ocr_failure_reason IS 'Reason for the most recent OCR failure, if any';

View File

@ -29,6 +29,8 @@ impl Database {
.bind(&document.ocr_status) .bind(&document.ocr_status)
.bind(&document.ocr_error) .bind(&document.ocr_error)
.bind(document.ocr_completed_at) .bind(document.ocr_completed_at)
.bind(document.ocr_retry_count)
.bind(&document.ocr_failure_reason)
.bind(&document.tags) .bind(&document.tags)
.bind(document.created_at) .bind(document.created_at)
.bind(document.updated_at) .bind(document.updated_at)
@ -36,8 +38,6 @@ impl Database {
.bind(&document.file_hash) .bind(&document.file_hash)
.bind(document.original_created_at) .bind(document.original_created_at)
.bind(document.original_modified_at) .bind(document.original_modified_at)
.bind(document.ocr_retry_count)
.bind(&document.ocr_failure_reason)
.bind(&document.source_metadata) .bind(&document.source_metadata)
.fetch_one(&self.pool) .fetch_one(&self.pool)
.await?; .await?;

View File

@ -109,6 +109,13 @@ async fn debug_ocr_content() {
.await .await
.expect("Upload should work"); .expect("Upload should work");
println!("📤 Document 1 upload response status: {}", doc1_response.status());
if !doc1_response.status().is_success() {
let status = doc1_response.status();
let error_text = doc1_response.text().await.unwrap_or_else(|_| "No response body".to_string());
panic!("Document 1 upload failed with status {}: {}", status, error_text);
}
let doc2_response = client let doc2_response = client
.post(&format!("{}/api/documents", get_base_url())) .post(&format!("{}/api/documents", get_base_url()))
.header("Authorization", format!("Bearer {}", token)) .header("Authorization", format!("Bearer {}", token))
@ -117,8 +124,15 @@ async fn debug_ocr_content() {
.await .await
.expect("Upload should work"); .expect("Upload should work");
let doc1: DocumentResponse = doc1_response.json().await.expect("Valid JSON"); println!("📤 Document 2 upload response status: {}", doc2_response.status());
let doc2: DocumentResponse = doc2_response.json().await.expect("Valid JSON"); if !doc2_response.status().is_success() {
let status = doc2_response.status();
let error_text = doc2_response.text().await.unwrap_or_else(|_| "No response body".to_string());
panic!("Document 2 upload failed with status {}: {}", status, error_text);
}
let doc1: DocumentResponse = doc1_response.json().await.expect("Valid JSON for doc1");
let doc2: DocumentResponse = doc2_response.json().await.expect("Valid JSON for doc2");
println!("📄 Document 1: {}", doc1.id); println!("📄 Document 1: {}", doc1.id);
println!("📄 Document 2: {}", doc2.id); println!("📄 Document 2: {}", doc2.id);