Complete coverage
This commit is contained in:
parent
de5888e9a0
commit
e136103ead
@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -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),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user