From 4735199a99248ca2dc9fb6dcac656823b6e9558b Mon Sep 17 00:00:00 2001 From: perf3ct Date: Fri, 20 Jun 2025 20:59:07 +0000 Subject: [PATCH] fix(tests): make sure that the document_deletion and document_upload jobs use environment variables --- tests/document_deletion_integration_tests.rs | 12 ++++++++++++ tests/document_upload_hash_duplicate_tests.rs | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/tests/document_deletion_integration_tests.rs b/tests/document_deletion_integration_tests.rs index 077dd8d..e0c162d 100644 --- a/tests/document_deletion_integration_tests.rs +++ b/tests/document_deletion_integration_tests.rs @@ -12,6 +12,17 @@ use uuid::Uuid; use readur::models::{DocumentResponse, CreateUser, LoginRequest, LoginResponse, UserRole}; +// Initialize test environment +fn init_test_env() { + use std::env; + + // Load test environment variables + dotenvy::from_filename(".env.test").ok(); + + // Ensure we're using the test database + env::set_var("DATABASE_URL", "postgresql://readur_test:readur_test@localhost:5433/readur_test"); +} + fn get_base_url() -> String { std::env::var("API_URL").unwrap_or_else(|_| "http://localhost:8000".to_string()) } @@ -450,6 +461,7 @@ async fn test_bulk_delete_mixed_existing_nonexistent() { #[tokio::test] async fn test_unauthorized_deletion() { + init_test_env(); let client = DocumentDeletionTestClient::new(); skip_if_server_down!(client); diff --git a/tests/document_upload_hash_duplicate_tests.rs b/tests/document_upload_hash_duplicate_tests.rs index 6fe8d9d..1116b71 100644 --- a/tests/document_upload_hash_duplicate_tests.rs +++ b/tests/document_upload_hash_duplicate_tests.rs @@ -11,6 +11,17 @@ use readur::{ models::{Document, CreateUser, UserRole}, }; +// Initialize test environment +fn init_test_env() { + use std::env; + + // Load test environment variables + dotenvy::from_filename(".env.test").ok(); + + // Ensure we're using the test database + env::set_var("DATABASE_URL", "postgresql://readur_test:readur_test@localhost:5433/readur_test"); +} + // Helper function to calculate file hash fn calculate_file_hash(data: &[u8]) -> String { let mut hasher = Sha256::new(); @@ -119,6 +130,7 @@ async fn test_document_upload_duplicate_detection_returns_existing() -> Result<( #[tokio::test] async fn test_document_upload_unique_content_processed() -> Result<()> { + init_test_env(); let state = create_test_app_state().await?; let user = create_test_user_with_suffix(&format!("upload_{}", uuid::Uuid::new_v4().simple()));