- Implement core Rust backend with FFmpeg integration - Add TheTVDB API client with token caching - Implement directory scanner with progress callbacks - Create file manager with rename and move operations - Add audit logging functionality - Implement file mapping for TV episode renaming - Build Node.js native addon via NAPI - Include comprehensive unit and integration tests - Update gitignore to exclude build artifacts and temp files Resolves #TBD
53 lines
1.6 KiB
Rust
53 lines
1.6 KiB
Rust
// Unit tests for MetadataExtractor
|
|
// These tests are copied from the lib tests since the methods are private
|
|
|
|
use movie_mapper::service::file_metadata::MetadataExtractor;
|
|
use std::path::Path;
|
|
|
|
#[test]
|
|
fn test_extract_metadata_returns_default_values() {
|
|
let extractor = MetadataExtractor::new();
|
|
|
|
// Create a temporary file that's not a valid media file
|
|
let temp_dir = tempfile::tempdir().unwrap();
|
|
let temp_file = temp_dir.path().join("test.txt");
|
|
{
|
|
use std::fs::File;
|
|
use std::io::Write;
|
|
let mut file = File::create(&temp_file).unwrap();
|
|
file.write_all(b"not a video").unwrap();
|
|
}
|
|
|
|
let result = extractor.extract_metadata(temp_file.as_path());
|
|
|
|
// Should not fail, just return default values
|
|
assert!(result.is_ok());
|
|
let file = result.unwrap();
|
|
assert_eq!(file.duration, "00:00");
|
|
assert_eq!(file.quality, "unknown");
|
|
assert_eq!(file.fps, "unknown");
|
|
}
|
|
|
|
#[test]
|
|
fn test_extract_quality_handles_missing_stream() {
|
|
let extractor = MetadataExtractor::new();
|
|
|
|
// Test with a non-existent file
|
|
let result = extractor.extract_quality(Path::new("/nonexistent/video.mp4"));
|
|
// Should return default values
|
|
assert!(result.is_ok());
|
|
let (quality, fps) = result.unwrap();
|
|
assert_eq!(quality, "unknown");
|
|
assert_eq!(fps, "unknown");
|
|
}
|
|
|
|
#[test]
|
|
fn test_extract_duration_handles_missing_file() {
|
|
let extractor = MetadataExtractor::new();
|
|
|
|
let result = extractor.extract_duration(Path::new("/nonexistent/video.mp4"));
|
|
// Should return default value
|
|
assert!(result.is_ok());
|
|
assert_eq!(result.unwrap(), "00:00");
|
|
}
|