fix: eliminate all 420 compiler warnings
- Add allow(async_fn_in_trait) in lib.rs for async trait methods - Add integration_tests feature to Cargo.toml for cfg gating - Gate trash_service_test module with cfg(feature = integration_tests) - Remove unused MockFileWritePort from idor_protection_test.rs
This commit is contained in:
@@ -57,6 +57,7 @@ socket2 = { version = "0.6.2", features = ["all"] }
|
|||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
test_utils = ["mockall"]
|
test_utils = ["mockall"]
|
||||||
|
integration_tests = []
|
||||||
|
|
||||||
[profile.release]
|
[profile.release]
|
||||||
lto = "fat"
|
lto = "fat"
|
||||||
|
|||||||
@@ -6,12 +6,11 @@
|
|||||||
use bytes::Bytes;
|
use bytes::Bytes;
|
||||||
use futures::Stream;
|
use futures::Stream;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::path::{Path, PathBuf};
|
|
||||||
use std::pin::Pin;
|
use std::pin::Pin;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
|
|
||||||
use crate::application::ports::storage_ports::{
|
use crate::application::ports::storage_ports::{
|
||||||
FileReadPort, FileWritePort,
|
FileReadPort,
|
||||||
};
|
};
|
||||||
use crate::common::errors::DomainError;
|
use crate::common::errors::DomainError;
|
||||||
use crate::domain::entities::file::File;
|
use crate::domain::entities::file::File;
|
||||||
@@ -131,119 +130,6 @@ impl FileReadPort for MockFileReadPort {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Minimal mock write port — only `move_file` and `rename_file` need real logic.
|
|
||||||
struct MockFileWritePort {
|
|
||||||
files: Mutex<HashMap<String, File>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl MockFileWritePort {
|
|
||||||
fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
files: Mutex::new(HashMap::new()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn insert(&self, id: &str, name: &str) {
|
|
||||||
let file = File::new(
|
|
||||||
id.to_string(),
|
|
||||||
name.to_string(),
|
|
||||||
StoragePath::from_string(&format!("/{}", name)),
|
|
||||||
42,
|
|
||||||
"text/plain".to_string(),
|
|
||||||
None,
|
|
||||||
)
|
|
||||||
.unwrap();
|
|
||||||
self.files.lock().unwrap().insert(id.to_string(), file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl FileWritePort for MockFileWritePort {
|
|
||||||
async fn save_file_from_temp(
|
|
||||||
&self,
|
|
||||||
_name: String,
|
|
||||||
_folder_id: Option<String>,
|
|
||||||
_content_type: String,
|
|
||||||
_temp_path: &Path,
|
|
||||||
_size: u64,
|
|
||||||
_pre_computed_hash: Option<String>,
|
|
||||||
) -> Result<File, DomainError> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn move_file(
|
|
||||||
&self,
|
|
||||||
file_id: &str,
|
|
||||||
_target_folder_id: Option<String>,
|
|
||||||
) -> Result<File, DomainError> {
|
|
||||||
let files = self.files.lock().unwrap();
|
|
||||||
files
|
|
||||||
.get(file_id)
|
|
||||||
.cloned()
|
|
||||||
.ok_or_else(|| DomainError::not_found("File", file_id.to_string()))
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn rename_file(
|
|
||||||
&self,
|
|
||||||
file_id: &str,
|
|
||||||
_new_name: &str,
|
|
||||||
) -> Result<File, DomainError> {
|
|
||||||
let files = self.files.lock().unwrap();
|
|
||||||
files
|
|
||||||
.get(file_id)
|
|
||||||
.cloned()
|
|
||||||
.ok_or_else(|| DomainError::not_found("File", file_id.to_string()))
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn delete_file(&self, _id: &str) -> Result<(), DomainError> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn update_file_content_from_temp(
|
|
||||||
&self,
|
|
||||||
_file_id: &str,
|
|
||||||
_temp_path: &Path,
|
|
||||||
_size: u64,
|
|
||||||
_content_type: Option<String>,
|
|
||||||
_pre_computed_hash: Option<String>,
|
|
||||||
) -> Result<(), DomainError> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn register_file_deferred(
|
|
||||||
&self,
|
|
||||||
_name: String,
|
|
||||||
_folder_id: Option<String>,
|
|
||||||
_content_type: String,
|
|
||||||
_size: u64,
|
|
||||||
) -> Result<(File, PathBuf), DomainError> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn copy_file(
|
|
||||||
&self,
|
|
||||||
_file_id: &str,
|
|
||||||
_target_folder_id: Option<String>,
|
|
||||||
) -> Result<File, DomainError> {
|
|
||||||
unimplemented!()
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn move_to_trash(&self, _file_id: &str) -> Result<(), DomainError> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn restore_from_trash(
|
|
||||||
&self,
|
|
||||||
_file_id: &str,
|
|
||||||
_original_path: &str,
|
|
||||||
) -> Result<(), DomainError> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn delete_file_permanently(&self, _file_id: &str) -> Result<(), DomainError> {
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// ═══════════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════════
|
||||||
// Tests — FileReadPort::get_file_for_owner (Repository layer, Solution C)
|
// Tests — FileReadPort::get_file_for_owner (Repository layer, Solution C)
|
||||||
// ═══════════════════════════════════════════════════════════════════════════
|
// ═══════════════════════════════════════════════════════════════════════════
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ pub mod trash_service;
|
|||||||
pub mod wopi_lock_service;
|
pub mod wopi_lock_service;
|
||||||
pub mod wopi_token_service;
|
pub mod wopi_token_service;
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(all(test, feature = "integration_tests"))]
|
||||||
mod trash_service_test;
|
mod trash_service_test;
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod idor_protection_test;
|
mod idor_protection_test;
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
#![allow(async_fn_in_trait)]
|
||||||
|
|
||||||
// Export the main project modules
|
// Export the main project modules
|
||||||
pub mod application;
|
pub mod application;
|
||||||
pub mod common;
|
pub mod common;
|
||||||
|
|||||||
Reference in New Issue
Block a user