ADR-0001: MediaItem absorbs LibraryItem fields (provider_id, external_id, collection_name, collection_type, synced_at, role/MediaRole). LibraryItem + LibraryItemRow deleted. All ports/adapters/tests updated. ADR-0002: schedule engine takes LibraryQuery instead of IProviderRegistry. Algorithmic blocks query library via search(), manual blocks via get_by_id(). get_stream_url removed from engine; provider_registry moved to ScheduleDeps for playback-time stream URL resolution in application layer. BlockContent provider_id field removed (meaningless when querying library).
77 lines
2.2 KiB
Rust
77 lines
2.2 KiB
Rust
use super::*;
|
|
|
|
#[test]
|
|
fn library_collection_new_and_getters() {
|
|
let col = LibraryCollection::new("col-1", "Movies");
|
|
assert_eq!(col.id(), "col-1");
|
|
assert_eq!(col.name(), "Movies");
|
|
assert!(col.collection_type().is_none());
|
|
}
|
|
|
|
#[test]
|
|
fn library_collection_from_persistence() {
|
|
let col = LibraryCollection::from_persistence(
|
|
"col-2".into(),
|
|
"TV Shows".into(),
|
|
Some("tvshows".into()),
|
|
);
|
|
assert_eq!(col.collection_type(), Some("tvshows"));
|
|
}
|
|
|
|
#[test]
|
|
fn sync_result_success() {
|
|
let r = LibrarySyncResult::new("jellyfin", 150, 1200);
|
|
assert_eq!(r.provider_id(), "jellyfin");
|
|
assert_eq!(r.items_found(), 150);
|
|
assert_eq!(r.duration_ms(), 1200);
|
|
assert!(r.error().is_none());
|
|
}
|
|
|
|
#[test]
|
|
fn sync_result_with_error() {
|
|
let r = LibrarySyncResult::with_error("jellyfin", 500, "connection refused");
|
|
assert_eq!(r.items_found(), 0);
|
|
assert_eq!(r.error(), Some("connection refused"));
|
|
}
|
|
|
|
#[test]
|
|
fn sync_log_entry_new_defaults() {
|
|
let entry = LibrarySyncLogEntry::new(1, "jellyfin", "2026-03-19T00:00:00Z");
|
|
assert_eq!(entry.id(), 1);
|
|
assert_eq!(entry.status(), SYNC_STATUS_RUNNING);
|
|
assert_eq!(entry.items_found(), 0);
|
|
assert!(entry.finished_at().is_none());
|
|
assert!(entry.error_msg().is_none());
|
|
}
|
|
|
|
#[test]
|
|
fn show_summary_getters() {
|
|
let show = ShowSummary::from_persistence(
|
|
"Breaking Bad".into(),
|
|
62,
|
|
5,
|
|
Some("http://thumb.jpg".into()),
|
|
vec!["Drama".into(), "Crime".into()],
|
|
);
|
|
assert_eq!(show.series_name(), "Breaking Bad");
|
|
assert_eq!(show.episode_count(), 62);
|
|
assert_eq!(show.season_count(), 5);
|
|
assert_eq!(show.genres().len(), 2);
|
|
}
|
|
|
|
#[test]
|
|
fn season_summary_getters() {
|
|
let season = SeasonSummary::from_persistence(1, 7, Some("http://s1.jpg".into()));
|
|
assert_eq!(season.season_number(), 1);
|
|
assert_eq!(season.episode_count(), 7);
|
|
assert_eq!(season.thumbnail_url(), Some("http://s1.jpg"));
|
|
}
|
|
|
|
#[test]
|
|
fn season_summary_new_defaults() {
|
|
let season = SeasonSummary::new(3, 13);
|
|
assert_eq!(season.season_number(), 3);
|
|
assert_eq!(season.episode_count(), 13);
|
|
assert!(season.thumbnail_url().is_none());
|
|
}
|