style: apply rust format + fix clippy warning
This commit is contained in:
@@ -7,9 +7,11 @@
|
||||
mod tests {
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::application::services::batch_operations::{BatchOperationService, BatchResult, BatchStats};
|
||||
use crate::application::services::file_retrieval_service::FileRetrievalService;
|
||||
use crate::application::services::batch_operations::{
|
||||
BatchOperationService, BatchResult, BatchStats,
|
||||
};
|
||||
use crate::application::services::file_management_service::FileManagementService;
|
||||
use crate::application::services::file_retrieval_service::FileRetrievalService;
|
||||
use crate::application::services::folder_service::FolderService;
|
||||
use crate::common::config::AppConfig;
|
||||
use crate::infrastructure::repositories::pg::file_blob_read_repository::FileBlobReadRepository;
|
||||
@@ -25,17 +27,24 @@ mod tests {
|
||||
let trash_result: Result<(), String> = Ok(());
|
||||
let id_for_result = folder_id.clone();
|
||||
let mapped = trash_result.map(|_| id_for_result);
|
||||
|
||||
|
||||
assert!(mapped.is_ok(), "Ok result should remain Ok after mapping");
|
||||
assert_eq!(mapped.unwrap(), folder_id, "Mapped result should contain the folder_id");
|
||||
assert_eq!(
|
||||
mapped.unwrap(),
|
||||
folder_id,
|
||||
"Mapped result should contain the folder_id"
|
||||
);
|
||||
|
||||
// Test Err maps to Err (preserved)
|
||||
let folder_id2 = "test-folder-id-2".to_string();
|
||||
let trash_result2: Result<(), String> = Err("Some error".to_string());
|
||||
let id_for_result2 = folder_id2.clone();
|
||||
let mapped2 = trash_result2.map(|_| id_for_result2);
|
||||
|
||||
assert!(mapped2.is_err(), "Err result should remain Err after mapping");
|
||||
|
||||
assert!(
|
||||
mapped2.is_err(),
|
||||
"Err result should remain Err after mapping"
|
||||
);
|
||||
}
|
||||
|
||||
/// Test that batch result counting works correctly
|
||||
@@ -56,16 +65,20 @@ mod tests {
|
||||
// Simulate processing 2 successes and 1 failure
|
||||
result.successful.push("id1".to_string());
|
||||
result.stats.successful += 1;
|
||||
|
||||
|
||||
result.successful.push("id3".to_string());
|
||||
result.stats.successful += 1;
|
||||
|
||||
|
||||
result.failed.push(("id2".to_string(), "error".to_string()));
|
||||
result.stats.failed += 1;
|
||||
|
||||
assert_eq!(result.stats.successful, 2, "Should have 2 successful");
|
||||
assert_eq!(result.stats.failed, 1, "Should have 1 failed");
|
||||
assert_eq!(result.successful.len(), 2, "Successful vector should have 2 items");
|
||||
assert_eq!(
|
||||
result.successful.len(),
|
||||
2,
|
||||
"Successful vector should have 2 items"
|
||||
);
|
||||
assert_eq!(result.failed.len(), 1, "Failed vector should have 1 item");
|
||||
}
|
||||
|
||||
@@ -75,18 +88,18 @@ mod tests {
|
||||
let folder_repo = Arc::new(FolderDbRepository::new_stub());
|
||||
let file_read_repo = Arc::new(FileBlobReadRepository::new_stub());
|
||||
let file_write_repo = Arc::new(FileBlobWriteRepository::new_stub());
|
||||
|
||||
|
||||
let file_retrieval = Arc::new(FileRetrievalService::new(file_read_repo));
|
||||
let file_management = Arc::new(FileManagementService::new(file_write_repo));
|
||||
let folder_service = Arc::new(FolderService::new(folder_repo));
|
||||
|
||||
|
||||
let _batch_service = BatchOperationService::new(
|
||||
file_retrieval,
|
||||
file_management,
|
||||
folder_service,
|
||||
AppConfig::default(),
|
||||
);
|
||||
|
||||
|
||||
// Service created successfully
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,8 @@ impl FileManagementUseCase for FileManagementService {
|
||||
// Verify file ownership first
|
||||
self.verify_owner(file_id, caller_id).await?;
|
||||
// Verify target folder ownership (prevents file from "disappearing")
|
||||
self.verify_target_folder_owner(&folder_id, caller_id).await?;
|
||||
self.verify_target_folder_owner(&folder_id, caller_id)
|
||||
.await?;
|
||||
self.move_file(file_id, folder_id).await
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user