fix(tests): make sure that the document_deletion and document_upload jobs use environment variables
This commit is contained in:
parent
a2d6c318db
commit
4735199a99
|
|
@ -12,6 +12,17 @@ use uuid::Uuid;
|
||||||
|
|
||||||
use readur::models::{DocumentResponse, CreateUser, LoginRequest, LoginResponse, UserRole};
|
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 {
|
fn get_base_url() -> String {
|
||||||
std::env::var("API_URL").unwrap_or_else(|_| "http://localhost:8000".to_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]
|
#[tokio::test]
|
||||||
async fn test_unauthorized_deletion() {
|
async fn test_unauthorized_deletion() {
|
||||||
|
init_test_env();
|
||||||
let client = DocumentDeletionTestClient::new();
|
let client = DocumentDeletionTestClient::new();
|
||||||
skip_if_server_down!(client);
|
skip_if_server_down!(client);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,17 @@ use readur::{
|
||||||
models::{Document, CreateUser, UserRole},
|
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
|
// Helper function to calculate file hash
|
||||||
fn calculate_file_hash(data: &[u8]) -> String {
|
fn calculate_file_hash(data: &[u8]) -> String {
|
||||||
let mut hasher = Sha256::new();
|
let mut hasher = Sha256::new();
|
||||||
|
|
@ -119,6 +130,7 @@ async fn test_document_upload_duplicate_detection_returns_existing() -> Result<(
|
||||||
|
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_document_upload_unique_content_processed() -> Result<()> {
|
async fn test_document_upload_unique_content_processed() -> Result<()> {
|
||||||
|
init_test_env();
|
||||||
let state = create_test_app_state().await?;
|
let state = create_test_app_state().await?;
|
||||||
let user = create_test_user_with_suffix(&format!("upload_{}", uuid::Uuid::new_v4().simple()));
|
let user = create_test_user_with_suffix(&format!("upload_{}", uuid::Uuid::new_v4().simple()));
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue