fix(tests): resolve issues with new config fields for user_watch in tests

This commit is contained in:
perfectra1n 2025-07-30 21:16:13 -07:00
parent 80800155e2
commit ffb33ae5ab
10 changed files with 47 additions and 6 deletions

27
fix_config_fields.sh Executable file
View File

@ -0,0 +1,27 @@
#\!/bin/bash
# List of test files that need Config struct fixes
files=(
"tests/integration_config_oidc_tests.rs"
"tests/integration_source_sync_cancellation_workflow_tests.rs"
"tests/integration_source_scheduler_tests.rs"
"tests/integration_webdav_hash_duplicate_tests.rs"
"tests/integration_stop_sync_functionality_tests.rs"
"tests/integration_universal_source_sync_tests.rs"
)
for file in "${files[@]}"; do
if [ -f "$file" ]; then
echo "Fixing $file..."
# Use sed to add the missing fields after watch_folder line
sed -i.bak '/watch_folder: /a\
user_watch_base_dir: "./user_watch".to_string(),\
enable_per_user_watch: false,' "$file"
# Remove backup file
rm "${file}.bak" 2>/dev/null || true
echo "Fixed $file"
else
echo "File not found: $file"
fi
done

View File

@ -66,6 +66,7 @@ async fn create_test_app_state() -> Arc<AppState> {
queue_service,
oidc_client: None,
sync_progress_tracker,
user_watch_service: None,
})
}

View File

@ -53,7 +53,8 @@ mod tests {
jwt_secret: "test-secret".to_string(),
upload_path: "./test-uploads".to_string(),
watch_folder: "./test-watch".to_string(),
allowed_file_types: vec!["pdf".to_string()],
user_watch_base_dir: "./user_watch".to_string(),
enable_per_user_watch: false, allowed_file_types: vec!["pdf".to_string()],
watch_interval_seconds: Some(30),
file_stability_check_ms: Some(500),
max_file_age_hours: None,

View File

@ -29,6 +29,8 @@ async fn create_test_app_state() -> Arc<AppState> {
jwt_secret: "test_secret".to_string(),
upload_path: "/tmp/test_uploads".to_string(),
watch_folder: "/tmp/watch".to_string(),
user_watch_base_dir: "./user_watch".to_string(),
enable_per_user_watch: false,
allowed_file_types: vec!["pdf".to_string(), "txt".to_string()],
watch_interval_seconds: Some(10),
file_stability_check_ms: Some(1000),

View File

@ -174,7 +174,8 @@ async fn create_test_app_state() -> Arc<AppState> {
jwt_secret: "test_secret".to_string(),
upload_path: "/tmp/test_uploads".to_string(),
watch_folder: "/tmp/test_watch".to_string(),
allowed_file_types: vec!["pdf".to_string(), "txt".to_string()],
user_watch_base_dir: "./user_watch".to_string(),
enable_per_user_watch: false, allowed_file_types: vec!["pdf".to_string(), "txt".to_string()],
watch_interval_seconds: Some(30),
file_stability_check_ms: Some(500),
max_file_age_hours: None,

View File

@ -44,7 +44,8 @@ async fn create_test_app_state() -> Arc<AppState> {
jwt_secret: "test_secret_for_sync_cancellation".to_string(),
upload_path: "/tmp/test_uploads_sync_cancel".to_string(),
watch_folder: "/tmp/watch_sync_cancel".to_string(),
allowed_file_types: vec!["pdf".to_string(), "txt".to_string(), "jpg".to_string(), "png".to_string()],
user_watch_base_dir: "./user_watch".to_string(),
enable_per_user_watch: false, allowed_file_types: vec!["pdf".to_string(), "txt".to_string(), "jpg".to_string(), "png".to_string()],
watch_interval_seconds: Some(30),
file_stability_check_ms: Some(500),
max_file_age_hours: Some(24),
@ -79,6 +80,7 @@ async fn create_test_app_state() -> Arc<AppState> {
queue_service,
oidc_client: None,
sync_progress_tracker,
user_watch_service: None,
};
// Wrap in Arc for sharing
@ -98,6 +100,7 @@ async fn create_test_app_state() -> Arc<AppState> {
queue_service: state_arc.queue_service.clone(),
oidc_client: None,
sync_progress_tracker: state_arc.sync_progress_tracker.clone(),
user_watch_service: None,
})
}

View File

@ -36,7 +36,8 @@ async fn create_test_app_state() -> Arc<AppState> {
jwt_secret: "test_secret".to_string(),
upload_path: "/tmp/test_uploads".to_string(),
watch_folder: "/tmp/watch".to_string(),
allowed_file_types: vec!["pdf".to_string(), "txt".to_string()],
user_watch_base_dir: "./user_watch".to_string(),
enable_per_user_watch: false, allowed_file_types: vec!["pdf".to_string(), "txt".to_string()],
watch_interval_seconds: Some(10),
file_stability_check_ms: Some(1000),
max_file_age_hours: Some(24),

View File

@ -137,7 +137,8 @@ async fn create_test_app_state() -> Arc<AppState> {
jwt_secret: "test_secret".to_string(),
upload_path: "/tmp/test_uploads".to_string(),
watch_folder: "/tmp/test_watch".to_string(),
allowed_file_types: vec!["pdf".to_string(), "txt".to_string()],
user_watch_base_dir: "./user_watch".to_string(),
enable_per_user_watch: false, allowed_file_types: vec!["pdf".to_string(), "txt".to_string()],
watch_interval_seconds: Some(30),
file_stability_check_ms: Some(500),
max_file_age_hours: None,

View File

@ -126,7 +126,9 @@ async fn create_test_app_state() -> Result<Arc<AppState>> {
jwt_secret: "test-secret".to_string(),
upload_path: "./test-uploads".to_string(),
watch_folder: "./test-watch".to_string(),
allowed_file_types: vec!["pdf".to_string(), "txt".to_string()],
user_watch_base_dir: "./user_watch".to_string(),
enable_per_user_watch: false,
allowed_file_types: vec!["pdf".to_string(), "txt".to_string()],
watch_interval_seconds: Some(30),
file_stability_check_ms: Some(500),
max_file_age_hours: None,

View File

@ -85,6 +85,8 @@ async fn setup_test_app() -> (Router, Arc<AppState>) {
server_address: "127.0.0.1:0".to_string(),
upload_path: "/tmp/test_uploads".to_string(),
watch_folder: "/tmp/test_watch".to_string(),
user_watch_base_dir: "./user_watch".to_string(),
enable_per_user_watch: false,
jwt_secret: "test_jwt_secret_for_integration_tests".to_string(),
allowed_file_types: vec!["pdf".to_string(), "png".to_string()],
watch_interval_seconds: Some(10),