feat: 完善素材导入模特绑定功能并添加测试
- 添加测试验证 CreateMaterialRequest 的 model_id 字段 - 添加测试验证 Material::new_with_model 方法 - 更新测试导入以包含新的 model_id 字段 - 确保数据结构和方法的正确性
This commit is contained in:
parent
ee7a1f6a1a
commit
3f90013a47
|
|
@ -2,7 +2,10 @@
|
|||
mod tests {
|
||||
use crate::business::services::material_service::MaterialService;
|
||||
use crate::data::models::material::{MaterialType, ProcessingStatus};
|
||||
use crate::data::models::project::Project;
|
||||
use crate::data::repositories::material_repository::MaterialRepository;
|
||||
use crate::data::repositories::project_repository::ProjectRepository;
|
||||
use crate::data::repositories::model_repository::ModelRepository;
|
||||
use crate::infrastructure::database::Database;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use tempfile::tempdir;
|
||||
|
|
@ -228,6 +231,7 @@ mod tests {
|
|||
file_paths: vec![test_file_path],
|
||||
auto_process: true,
|
||||
max_segment_duration: Some(300.0),
|
||||
model_id: None,
|
||||
};
|
||||
|
||||
// 创建处理配置
|
||||
|
|
@ -264,4 +268,34 @@ mod tests {
|
|||
// 这个测试需要实际的数据库连接,所以暂时跳过
|
||||
// 在实际项目中,可以使用模拟数据库或测试数据库
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_import_materials_with_model_binding() {
|
||||
// 测试素材导入时的模特绑定功能
|
||||
// 由于测试环境复杂性,这里只验证数据结构的正确性
|
||||
|
||||
// 验证 CreateMaterialRequest 包含 model_id 字段
|
||||
let request = crate::data::models::material::CreateMaterialRequest {
|
||||
project_id: "test_project".to_string(),
|
||||
file_paths: vec!["test.mp4".to_string()],
|
||||
auto_process: true,
|
||||
max_segment_duration: Some(300.0),
|
||||
model_id: Some("test_model_id".to_string()),
|
||||
};
|
||||
|
||||
assert_eq!(request.model_id, Some("test_model_id".to_string()));
|
||||
|
||||
// 验证 Material::new_with_model 方法
|
||||
let material = crate::data::models::material::Material::new_with_model(
|
||||
"project_id".to_string(),
|
||||
"test.mp4".to_string(),
|
||||
"/path/to/test.mp4".to_string(),
|
||||
1024,
|
||||
"hash123".to_string(),
|
||||
crate::data::models::material::MaterialType::Video,
|
||||
Some("model_id".to_string()),
|
||||
);
|
||||
|
||||
assert_eq!(material.model_id, Some("model_id".to_string()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue