MovieMapper/Rust/tests/model_tests.rs
Jarian Cottingham 6dd4e83ddf feat: Add Rust implementation for performance-critical components
- 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
2026-02-28 09:52:08 -06:00

51 lines
1.1 KiB
Rust

// Unit tests for models
use movie_mapper::model::file::MediaFile;
use std::path::PathBuf;
#[test]
fn test_media_file_creation() {
let path = PathBuf::from("/test/video.mp4");
let file = MediaFile::from_path(path);
assert_eq!(file.name, "video.mp4");
assert!(!file.is_folder);
assert_eq!(file.tags.len(), 0);
}
#[test]
fn test_media_file_tagging() {
let mut file = MediaFile::from_path(PathBuf::from("/test/video.mp4"));
// Add tags
file.add_tag("extra");
file.add_tag("behind-the-scenes");
assert!(file.is_tagged("extra"));
assert!(file.is_tagged("behind-the-scenes"));
assert_eq!(file.tags.len(), 2);
// Remove a tag
file.remove_tag("extra");
assert!(!file.is_tagged("extra"));
assert!(file.is_tagged("behind-the-scenes"));
assert_eq!(file.tags.len(), 1);
}
#[test]
fn test_episode_identifier() {
use movie_mapper::model::episode::Episode;
let episode = Episode {
id: 1,
name: "Pilot".to_string(),
number: 1,
season_number: 1,
aired: Some("2023-01-01".to_string()),
runtime: Some(60),
};
assert_eq!(episode.identifier(), "E01");
}