diff --git a/src/core/musichoard/filter.rs b/src/core/musichoard/filter.rs index a95c472..b77afd9 100644 --- a/src/core/musichoard/filter.rs +++ b/src/core/musichoard/filter.rs @@ -66,11 +66,11 @@ mod tests { AlbumField::PrimaryType(Some(AlbumPrimaryType::Album)), ]], except: vec![vec![ + AlbumField::Ownership(AlbumOwnership::None), AlbumField::SecondaryType(AlbumSecondaryType::Compilation), AlbumField::SecondaryType(AlbumSecondaryType::Soundtrack), AlbumField::SecondaryType(AlbumSecondaryType::Live), AlbumField::SecondaryType(AlbumSecondaryType::Demo), - AlbumField::Ownership(AlbumOwnership::None), ]], } } @@ -91,6 +91,7 @@ mod tests { fn test_album() -> Album { let mut album = Album::new(AlbumId::new("An Album")); + album.meta.info.primary_type = Some(AlbumPrimaryType::Album); album.tracks.push(test_track()); album } @@ -118,7 +119,29 @@ mod tests { #[test] fn filter_secondary_type() { - let filter = test_filter() + let filter = test_filter(); + let mut album = test_album(); + + assert!(filter.filter_album(&album)); + + // Non-filtered type. + let types = &mut album.meta.info.secondary_types; + types.push(AlbumSecondaryType::AudioDrama); + assert!(filter.filter_album(&album)); + + // Filtered type. + let types = &mut album.meta.info.secondary_types; + types.push(AlbumSecondaryType::Live); + assert!(!filter.filter_album(&album)); + + // Remove non-filtered type. + album.meta.info.secondary_types.remove(0); + assert!(!filter.filter_album(&album)); + + // Add another filtered type. + let types = &mut album.meta.info.secondary_types; + types.push(AlbumSecondaryType::Soundtrack); + assert!(!filter.filter_album(&album)); } #[test]