feat(tests): fix ocr_retry issues in tests
This commit is contained in:
parent
ae33b25133
commit
ffad8c4561
|
|
@ -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';
|
||||
|
|
@ -29,6 +29,8 @@ impl Database {
|
|||
.bind(&document.ocr_status)
|
||||
.bind(&document.ocr_error)
|
||||
.bind(document.ocr_completed_at)
|
||||
.bind(document.ocr_retry_count)
|
||||
.bind(&document.ocr_failure_reason)
|
||||
.bind(&document.tags)
|
||||
.bind(document.created_at)
|
||||
.bind(document.updated_at)
|
||||
|
|
@ -36,8 +38,6 @@ impl Database {
|
|||
.bind(&document.file_hash)
|
||||
.bind(document.original_created_at)
|
||||
.bind(document.original_modified_at)
|
||||
.bind(document.ocr_retry_count)
|
||||
.bind(&document.ocr_failure_reason)
|
||||
.bind(&document.source_metadata)
|
||||
.fetch_one(&self.pool)
|
||||
.await?;
|
||||
|
|
|
|||
|
|
@ -109,6 +109,13 @@ async fn debug_ocr_content() {
|
|||
.await
|
||||
.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
|
||||
.post(&format!("{}/api/documents", get_base_url()))
|
||||
.header("Authorization", format!("Bearer {}", token))
|
||||
|
|
@ -117,8 +124,15 @@ async fn debug_ocr_content() {
|
|||
.await
|
||||
.expect("Upload should work");
|
||||
|
||||
let doc1: DocumentResponse = doc1_response.json().await.expect("Valid JSON");
|
||||
let doc2: DocumentResponse = doc2_response.json().await.expect("Valid JSON");
|
||||
println!("📤 Document 2 upload response status: {}", doc2_response.status());
|
||||
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 2: {}", doc2.id);
|
||||
|
|
|
|||
Loading…
Reference in New Issue