Add a filtering tool to only show only certain release group types #252
@ -148,7 +148,14 @@ impl<Database, Library> IMusicHoardBasePrivate for MusicHoard<Database, Library>
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::core::testmod::FULL_COLLECTION;
|
||||
use crate::{
|
||||
collection::{
|
||||
album::{AlbumMeta, AlbumPrimaryType},
|
||||
artist::ArtistMeta,
|
||||
},
|
||||
core::testmod::FULL_COLLECTION,
|
||||
filter::AlbumField,
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
@ -321,4 +328,29 @@ mod tests {
|
||||
mh.collection = mh.merge_collections();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -58,7 +58,7 @@ mod tests {
|
||||
|
||||
use super::*;
|
||||
|
||||
fn test_filter() -> CollectionFilter {
|
||||
pub fn test_filter() -> CollectionFilter {
|
||||
CollectionFilter {
|
||||
include: vec![vec![
|
||||
AlbumField::PrimaryType(None),
|
||||
|
Loading…
x
Reference in New Issue
Block a user