Add a filtering tool to only show only certain release group types #252

Merged
wojtek merged 14 commits from 161---add-a-filtering-tool-to-only-show-only-certain-release-group-types into main 2025-01-04 22:42:27 +01:00
2 changed files with 34 additions and 2 deletions
Showing only changes of commit e136103ead - Show all commits

View File

@ -148,7 +148,14 @@ impl<Database, Library> IMusicHoardBasePrivate for MusicHoard<Database, Library>
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use crate::core::testmod::FULL_COLLECTION; use crate::{
collection::{
album::{AlbumMeta, AlbumPrimaryType},
artist::ArtistMeta,
},
core::testmod::FULL_COLLECTION,
filter::AlbumField,
};
use super::*; use super::*;
@ -321,4 +328,29 @@ mod tests {
mh.collection = mh.merge_collections(); mh.collection = mh.merge_collections();
assert_eq!(expected, mh.collection); assert_eq!(expected, mh.collection);
} }
#[test]
fn filtered() {
let mut mh = MusicHoard::default();
mh.collection = vec![Artist {
meta: ArtistMeta::new(ArtistId::new("Artist")),
albums: vec![
Album::new(AlbumId::new("Album 1")),
Album::new(AlbumId::new("Album 2")),
],
}];
mh.collection[0].albums[0].meta.info.primary_type = Some(AlbumPrimaryType::Ep);
mh.collection[0].albums[0].meta.info.primary_type = Some(AlbumPrimaryType::Album);
mh.set_filter(CollectionFilter {
include: vec![vec![AlbumField::PrimaryType(Some(AlbumPrimaryType::Album))]],
except: vec![],
});
assert_eq!(mh.get_collection().len(), 1);
assert_eq!(mh.get_filtered().len(), 1);
assert_eq!(mh.get_collection()[0].albums.len(), 2);
assert_eq!(mh.get_filtered()[0].albums.len(), 1);
}
} }

View File

@ -58,7 +58,7 @@ mod tests {
use super::*; use super::*;
fn test_filter() -> CollectionFilter { pub fn test_filter() -> CollectionFilter {
CollectionFilter { CollectionFilter {
include: vec![vec![ include: vec![vec![
AlbumField::PrimaryType(None), AlbumField::PrimaryType(None),