Artist indexing test
This commit is contained in:
parent
0c12729983
commit
c1f24ce96b
1 changed files with 27 additions and 20 deletions
|
@ -510,9 +510,10 @@ mod test {
|
||||||
artists: Vec<String>,
|
artists: Vec<String>,
|
||||||
composers: Vec<String>,
|
composers: Vec<String>,
|
||||||
lyricists: Vec<String>,
|
lyricists: Vec<String>,
|
||||||
expect_unlisted: bool,
|
expect_performer: bool,
|
||||||
expect_albums: bool,
|
expect_additional_performer: bool,
|
||||||
expect_featured_on: bool,
|
expect_composer: bool,
|
||||||
|
expect_lyricist: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
let test_cases = vec![
|
let test_cases = vec![
|
||||||
|
@ -522,41 +523,43 @@ mod test {
|
||||||
artists: vec![artist_name.to_string()],
|
artists: vec![artist_name.to_string()],
|
||||||
composers: vec![artist_name.to_string()],
|
composers: vec![artist_name.to_string()],
|
||||||
lyricists: vec![artist_name.to_string()],
|
lyricists: vec![artist_name.to_string()],
|
||||||
expect_albums: true,
|
expect_performer: true,
|
||||||
|
expect_composer: true,
|
||||||
|
expect_lyricist: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
// Only tagged as artist
|
// Only tagged as artist
|
||||||
TestCase {
|
TestCase {
|
||||||
artists: vec![artist_name.to_string()],
|
artists: vec![artist_name.to_string()],
|
||||||
expect_albums: true,
|
expect_performer: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
// Only tagged as artist w/ distinct album artist
|
// Only tagged as artist w/ distinct album artist
|
||||||
TestCase {
|
TestCase {
|
||||||
album_artists: vec![other_artist_name.to_string()],
|
album_artists: vec![other_artist_name.to_string()],
|
||||||
artists: vec![artist_name.to_string()],
|
artists: vec![artist_name.to_string()],
|
||||||
expect_featured_on: true,
|
expect_additional_performer: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
// Tagged as artist and within album artists
|
// Tagged as artist and within album artists
|
||||||
TestCase {
|
TestCase {
|
||||||
album_artists: vec![artist_name.to_string(), other_artist_name.to_string()],
|
album_artists: vec![artist_name.to_string(), other_artist_name.to_string()],
|
||||||
artists: vec![artist_name.to_string()],
|
artists: vec![artist_name.to_string()],
|
||||||
expect_albums: true,
|
expect_performer: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
// Only tagged as composer
|
// Only tagged as composer
|
||||||
TestCase {
|
TestCase {
|
||||||
artists: vec![other_artist_name.to_string()],
|
artists: vec![other_artist_name.to_string()],
|
||||||
composers: vec![artist_name.to_string()],
|
composers: vec![artist_name.to_string()],
|
||||||
expect_unlisted: true,
|
expect_composer: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
// Only tagged as lyricist
|
// Only tagged as lyricist
|
||||||
TestCase {
|
TestCase {
|
||||||
artists: vec![other_artist_name.to_string()],
|
artists: vec![other_artist_name.to_string()],
|
||||||
lyricists: vec![artist_name.to_string()],
|
lyricists: vec![artist_name.to_string()],
|
||||||
expect_unlisted: true,
|
expect_lyricist: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -575,15 +578,7 @@ mod test {
|
||||||
let artist_key = ArtistKey {
|
let artist_key = ArtistKey {
|
||||||
name: strings.get(artist_name),
|
name: strings.get(artist_name),
|
||||||
};
|
};
|
||||||
let artist = collection.get_artist(&strings, artist_key);
|
let artist = collection.get_artist(&strings, artist_key).unwrap();
|
||||||
|
|
||||||
let artist = match test.expect_unlisted {
|
|
||||||
true => {
|
|
||||||
assert!(artist.is_none());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
false => artist.unwrap(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let names = |a: &Vec<Album>| {
|
let names = |a: &Vec<Album>| {
|
||||||
a.iter()
|
a.iter()
|
||||||
|
@ -591,13 +586,13 @@ mod test {
|
||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
};
|
};
|
||||||
|
|
||||||
if test.expect_albums {
|
if test.expect_performer {
|
||||||
assert_eq!(names(&artist.albums_as_performer), vec![album_name]);
|
assert_eq!(names(&artist.albums_as_performer), vec![album_name]);
|
||||||
} else {
|
} else {
|
||||||
assert!(names(&artist.albums_as_performer).is_empty());
|
assert!(names(&artist.albums_as_performer).is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
if test.expect_featured_on {
|
if test.expect_additional_performer {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
names(&artist.albums_as_additional_performer),
|
names(&artist.albums_as_additional_performer),
|
||||||
vec![album_name]
|
vec![album_name]
|
||||||
|
@ -605,6 +600,18 @@ mod test {
|
||||||
} else {
|
} else {
|
||||||
assert!(names(&artist.albums_as_additional_performer).is_empty());
|
assert!(names(&artist.albums_as_additional_performer).is_empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if test.expect_composer {
|
||||||
|
assert_eq!(names(&artist.albums_as_composer), vec![album_name]);
|
||||||
|
} else {
|
||||||
|
assert!(names(&artist.albums_as_composer).is_empty());
|
||||||
|
}
|
||||||
|
|
||||||
|
if test.expect_lyricist {
|
||||||
|
assert_eq!(names(&artist.albums_as_lyricist), vec![album_name]);
|
||||||
|
} else {
|
||||||
|
assert!(names(&artist.albums_as_lyricist).is_empty());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue