Compare commits

...

2 Commits

Author SHA1 Message Date
5abac79414 Complete lints 2024-10-06 13:31:15 +02:00
246f35e715 Clippy lints 2024-10-06 12:47:14 +02:00
12 changed files with 129 additions and 109 deletions

View File

@ -2,12 +2,10 @@
pub mod album;
pub mod artist;
pub mod merge;
pub mod musicbrainz;
pub mod track;
mod merge;
pub use merge::MergeCollections;
use std::fmt::{self, Display};
/// The [`Collection`] alias type for convenience.

View File

@ -2,7 +2,8 @@ use crate::core::{
collection::{
album::{Album, AlbumId},
artist::{Artist, ArtistId},
Collection, MergeCollections,
merge::MergeCollections,
Collection,
},
musichoard::{Error, MusicHoard},
};

View File

@ -1,5 +1,7 @@
use std::mem;
use crate::{
collection::{album::AlbumInfo, artist::ArtistInfo},
collection::{album::AlbumInfo, artist::ArtistInfo, merge::Merge},
core::{
collection::{
album::{Album, AlbumId, AlbumSeq},
@ -24,7 +26,7 @@ pub trait IMusicHoardDatabase {
) -> Result<(), Error>;
fn clear_artist_sort<Id: AsRef<ArtistId>>(&mut self, artist_id: Id) -> Result<(), Error>;
fn set_artist_info<Id: AsRef<ArtistId>>(
fn merge_artist_info<Id: AsRef<ArtistId>>(
&mut self,
artist_id: Id,
info: ArtistInfo,
@ -66,7 +68,7 @@ pub trait IMusicHoardDatabase {
artist_id: ArtistIdRef,
album_id: AlbumIdRef,
) -> Result<(), Error>;
fn set_album_info<Id: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
fn merge_album_info<Id: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
&mut self,
artist_id: Id,
album_id: AlbumIdRef,
@ -132,12 +134,15 @@ impl<Database: IDatabase, Library> IMusicHoardDatabase for MusicHoard<Database,
)
}
fn set_artist_info<Id: AsRef<ArtistId>>(
fn merge_artist_info<Id: AsRef<ArtistId>>(
&mut self,
artist_id: Id,
info: ArtistInfo,
mut info: ArtistInfo,
) -> Result<(), Error> {
self.update_artist(artist_id.as_ref(), |artist| artist.meta.info = info)
self.update_artist(artist_id.as_ref(), |artist| {
mem::swap(&mut artist.meta.info, &mut info);
artist.meta.info.merge_in_place(info);
})
}
fn clear_artist_info<Id: AsRef<ArtistId>>(&mut self, artist_id: Id) -> Result<(), Error> {
@ -216,14 +221,15 @@ impl<Database: IDatabase, Library> IMusicHoardDatabase for MusicHoard<Database,
)
}
fn set_album_info<Id: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
fn merge_album_info<Id: AsRef<ArtistId>, AlbumIdRef: AsRef<AlbumId>>(
&mut self,
artist_id: Id,
album_id: AlbumIdRef,
info: AlbumInfo,
mut info: AlbumInfo,
) -> Result<(), Error> {
self.update_album(artist_id.as_ref(), album_id.as_ref(), |album| {
album.meta.info = info
mem::swap(&mut album.meta.info, &mut info);
album.meta.info.merge_in_place(info);
})
}
@ -457,7 +463,7 @@ mod tests {
let artist_id = ArtistId::new("an artist");
let actual_err = music_hoard
.set_artist_info(&artist_id, ArtistInfo::default())
.merge_artist_info(&artist_id, ArtistInfo::default())
.unwrap_err();
let expected_err =
Error::CollectionError(format!("artist '{artist_id}' is not in the collection"));
@ -484,13 +490,13 @@ mod tests {
// Setting a URL on an artist not in the collection is an error.
assert!(music_hoard
.set_artist_info(&artist_id_2, info.clone())
.merge_artist_info(&artist_id_2, info.clone())
.is_err());
assert_eq!(music_hoard.collection[0].meta.info.musicbrainz, expected);
// Setting a URL on an artist.
assert!(music_hoard
.set_artist_info(&artist_id, info.clone())
.merge_artist_info(&artist_id, info.clone())
.is_ok());
expected.replace(MbArtistRef::from_uuid_str(MBID).unwrap());
assert_eq!(music_hoard.collection[0].meta.info.musicbrainz, expected);
@ -679,14 +685,14 @@ mod tests {
// Seting info on an album not belonging to the artist is an error.
assert!(music_hoard
.set_album_info(&artist_id, &album_id_2, info.clone())
.merge_album_info(&artist_id, &album_id_2, info.clone())
.is_err());
let meta = &music_hoard.collection[0].albums[0].meta;
assert_eq!(meta.info, AlbumInfo::default());
// Set info.
assert!(music_hoard
.set_album_info(&artist_id, &album_id, info.clone())
.merge_album_info(&artist_id, &album_id, info.clone())
.is_ok());
let meta = &music_hoard.collection[0].albums[0].meta;
assert_eq!(meta.info, info);

View File

@ -5,7 +5,7 @@ use std::{
};
use musichoard::collection::{
album::{Album, AlbumMeta},
album::{Album, AlbumId},
artist::{Artist, ArtistId, ArtistMeta},
musicbrainz::{IMusicBrainzRef, MbArtistRef, MbRefOption, Mbid},
};
@ -151,13 +151,13 @@ impl AppMachine<FetchState> {
inner: AppInner,
fetch: FetchState,
artist_id: &ArtistId,
album: &AlbumMeta,
album_id: &AlbumId,
mbid: Mbid,
) -> App {
let f = |mb: &dyn IMbJobSender, rs, album, mbid| {
Self::submit_lookup_release_group_job(mb, rs, artist_id, album, mbid)
};
Self::app_lookup(f, inner, fetch, album, mbid)
Self::app_lookup(f, inner, fetch, album_id, mbid)
}
fn app_lookup<F, Meta>(
@ -243,12 +243,12 @@ impl AppMachine<FetchState> {
musicbrainz: &dyn IMbJobSender,
result_sender: ResultSender,
artist_id: &ArtistId,
album: &AlbumMeta,
album_id: &AlbumId,
mbid: Mbid,
) -> Result<(), DaemonError> {
let requests = VecDeque::from([MbParams::lookup_release_group(
artist_id.clone(),
album.clone(),
album_id.clone(),
mbid,
)]);
musicbrainz.submit_foreground_job(result_sender, requests)
@ -468,11 +468,11 @@ mod tests {
fn lookup_album_expectation(
job_sender: &mut MockIMbJobSender,
artist_id: &ArtistId,
album: &AlbumMeta,
album_id: &AlbumId,
) {
let requests = VecDeque::from([MbParams::lookup_release_group(
artist_id.clone(),
album.clone(),
album_id.clone(),
mbid(),
)]);
job_sender
@ -487,8 +487,8 @@ mod tests {
let mut mb_job_sender = MockIMbJobSender::new();
let artist_id = COLLECTION[1].meta.id.clone();
let album = COLLECTION[1].albums[0].meta.clone();
lookup_album_expectation(&mut mb_job_sender, &artist_id, &album);
let album_id = COLLECTION[1].albums[0].meta.id.clone();
lookup_album_expectation(&mut mb_job_sender, &artist_id, &album_id);
let music_hoard = music_hoard(COLLECTION.to_owned());
let inner = AppInner::new(music_hoard, mb_job_sender);
@ -496,7 +496,7 @@ mod tests {
let (_fetch_tx, fetch_rx) = mpsc::channel();
let fetch = FetchState::new(fetch_rx);
AppMachine::app_lookup_album(inner, fetch, &artist_id, &album, mbid());
AppMachine::app_lookup_album(inner, fetch, &artist_id, &album_id, mbid());
}
fn search_artist_expectation(job_sender: &mut MockIMbJobSender, artist: &ArtistMeta) {

View File

@ -24,7 +24,7 @@ impl GetInfoMeta for AlbumMeta {
trait GetInfo {
type InfoType;
fn into_info(&self, info: Self::InfoType) -> InfoOption<Self::InfoType>;
fn get_info(&self) -> InfoOption<Self::InfoType>;
}
enum InfoOption<T> {
@ -35,7 +35,8 @@ enum InfoOption<T> {
impl GetInfo for MatchOption<ArtistMeta> {
type InfoType = ArtistInfo;
fn into_info(&self, mut info: Self::InfoType) -> InfoOption<Self::InfoType> {
fn get_info(&self) -> InfoOption<Self::InfoType> {
let mut info = ArtistInfo::default();
match self {
MatchOption::Some(option) => info.musicbrainz = option.entity.info.musicbrainz.clone(),
MatchOption::CannotHaveMbid => info.musicbrainz = MbRefOption::CannotHaveMbid,
@ -48,7 +49,8 @@ impl GetInfo for MatchOption<ArtistMeta> {
impl GetInfo for MatchOption<AlbumMeta> {
type InfoType = AlbumInfo;
fn into_info(&self, mut info: Self::InfoType) -> InfoOption<Self::InfoType> {
fn get_info(&self) -> InfoOption<Self::InfoType> {
let mut info = AlbumInfo::default();
match self {
MatchOption::Some(option) => info = option.entity.info.clone(),
MatchOption::CannotHaveMbid => info.musicbrainz = MbRefOption::CannotHaveMbid,
@ -60,7 +62,7 @@ impl GetInfo for MatchOption<AlbumMeta> {
trait ExtractInfo {
type InfoType;
fn extract_info(&self, index: usize, info: Self::InfoType) -> InfoOption<Self::InfoType>;
fn extract_info(&self, index: usize) -> InfoOption<Self::InfoType>;
}
impl<T: GetInfoMeta> ExtractInfo for Vec<MatchOption<T>>
@ -70,8 +72,8 @@ where
{
type InfoType = T::InfoType;
fn extract_info(&self, index: usize, info: Self::InfoType) -> InfoOption<Self::InfoType> {
self.get(index).unwrap().into_info(info)
fn extract_info(&self, index: usize) -> InfoOption<Self::InfoType> {
self.get(index).unwrap().get_info()
}
}
@ -225,22 +227,16 @@ impl IAppInteractMatch for AppMachine<MatchState> {
let mh = &mut self.inner.music_hoard;
let result = match self.state.current {
EntityMatches::Artist(ref mut matches) => {
let info: ArtistInfo = matches.matching.info.clone();
match matches.list.extract_info(index, info) {
InfoOption::Info(info) => mh.set_artist_info(&matches.matching.id, info),
InfoOption::NeedInput => return self.get_input(),
EntityMatches::Artist(ref mut matches) => match matches.list.extract_info(index) {
InfoOption::Info(info) => mh.merge_artist_info(&matches.matching.id, info),
InfoOption::NeedInput => return self.get_input(),
},
EntityMatches::Album(ref mut matches) => match matches.list.extract_info(index) {
InfoOption::Info(info) => {
mh.merge_album_info(&matches.artist, &matches.matching, info)
}
}
EntityMatches::Album(ref mut matches) => {
let info: AlbumInfo = matches.matching.info.clone();
match matches.list.extract_info(index, info) {
InfoOption::Info(info) => {
mh.set_album_info(&matches.artist, &matches.matching.id, info)
}
InfoOption::NeedInput => return self.get_input(),
}
}
InfoOption::NeedInput => return self.get_input(),
},
};
if let Err(err) = result {
@ -318,9 +314,13 @@ mod tests {
EntityMatches::artist_lookup(artist, lookup)
}
fn album_meta() -> AlbumMeta {
fn album_id() -> AlbumId {
AlbumId::new("Album")
}
fn album_meta(id: AlbumId) -> AlbumMeta {
AlbumMeta::new(
AlbumId::new("Album"),
id,
AlbumDate::new(Some(1990), Some(5), None),
AlbumInfo::new(
MbRefOption::Some(mbid().into()),
@ -332,25 +332,27 @@ mod tests {
fn album_match() -> EntityMatches {
let artist_id = ArtistId::new("Artist");
let album = album_meta();
let album_id = album_id();
let album_meta = album_meta(album_id.clone());
let album_1 = album.clone();
let album_1 = album_meta.clone();
let album_match_1 = Entity::with_score(album_1, 100);
let mut album_2 = album.clone();
let mut album_2 = album_meta.clone();
album_2.id.title.push_str(" extra title part");
album_2.info.secondary_types.pop();
let album_match_2 = Entity::with_score(album_2, 100);
let list = vec![album_match_1.clone(), album_match_2.clone()];
EntityMatches::album_search(artist_id, album, list)
EntityMatches::album_search(artist_id, album_id, list)
}
fn album_lookup() -> EntityMatches {
let artist_id = ArtistId::new("Artist");
let album = album_meta();
let lookup = Entity::new(album.clone());
EntityMatches::album_lookup(artist_id, album, lookup)
let album_id = album_id();
let album_meta = album_meta(album_id.clone());
let lookup = Entity::new(album_meta.clone());
EntityMatches::album_lookup(artist_id, album_id, lookup)
}
fn fetch_state() -> FetchState {
@ -393,10 +395,10 @@ mod tests {
match matches_info {
EntityMatches::Album(_) => {
let album_id = AlbumId::new("Album");
let mut info = album_meta().info;
let mut info = album_meta(album_id.clone()).info;
info.musicbrainz = MbRefOption::CannotHaveMbid;
music_hoard
.expect_set_album_info()
.expect_merge_album_info()
.with(eq(artist_id.clone()), eq(album_id.clone()), eq(info))
.times(1)
.return_once(|_, _, _| Ok(()));
@ -405,7 +407,7 @@ mod tests {
let mut info = artist_meta().info;
info.musicbrainz = MbRefOption::CannotHaveMbid;
music_hoard
.expect_set_artist_info()
.expect_merge_artist_info()
.with(eq(artist_id.clone()), eq(info))
.times(1)
.return_once(|_, _| Ok(()));
@ -489,7 +491,7 @@ mod tests {
EntityMatches::Artist(_) => {
let meta = artist_meta();
music_hoard
.expect_set_artist_info()
.expect_merge_artist_info()
.with(eq(meta.id), eq(meta.info))
.times(1)
.return_once(|_, _| Ok(()));
@ -511,9 +513,9 @@ mod tests {
match matches_info {
EntityMatches::Artist(_) => panic!(),
EntityMatches::Album(matches) => {
let meta = album_meta();
let meta = album_meta(album_id());
music_hoard
.expect_set_album_info()
.expect_merge_album_info()
.with(eq(matches.artist), eq(meta.id), eq(meta.info))
.times(1)
.return_once(|_, _, _| Ok(()));
@ -535,7 +537,7 @@ mod tests {
match matches_info {
EntityMatches::Album(_) => panic!(),
EntityMatches::Artist(_) => {
music_hoard.expect_set_artist_info().return_once(|_, _| {
music_hoard.expect_merge_artist_info().return_once(|_, _| {
Err(musichoard::Error::DatabaseError(String::from("error")))
});
}
@ -622,7 +624,7 @@ mod tests {
let album = AlbumMeta::new("Album", 1990, AlbumInfo::default());
let requests = VecDeque::from([MbParams::lookup_release_group(
artist_id.clone(),
album.clone(),
album.id.clone(),
mbid(),
)]);
mb_job_sender
@ -632,7 +634,7 @@ mod tests {
let matches_vec: Vec<Entity<AlbumMeta>> = vec![];
let album_match =
EntityMatches::album_search(artist_id.clone(), album.clone(), matches_vec);
EntityMatches::album_search(artist_id.clone(), album.id.clone(), matches_vec);
let matches = AppMachine::match_state(
inner_with_mb(music_hoard(vec![]), mb_job_sender),
match_state(album_match),

View File

@ -6,7 +6,7 @@ use ratatui::widgets::ListState;
pub use selection::{Category, Selection};
use musichoard::collection::{
album::AlbumMeta,
album::{AlbumId, AlbumMeta},
artist::{ArtistId, ArtistMeta},
Collection,
};
@ -235,7 +235,7 @@ pub struct ArtistMatches {
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct AlbumMatches {
pub artist: ArtistId,
pub matching: AlbumMeta,
pub matching: AlbumId,
pub list: Vec<MatchOption<AlbumMeta>>,
}
@ -256,7 +256,7 @@ impl EntityMatches {
pub fn album_search<M: Into<MatchOption<AlbumMeta>>>(
artist: ArtistId,
matching: AlbumMeta,
matching: AlbumId,
list: Vec<M>,
) -> Self {
let list = list.into_iter().map(Into::into).collect();
@ -274,7 +274,7 @@ impl EntityMatches {
pub fn album_lookup<M: Into<MatchOption<AlbumMeta>>>(
artist: ArtistId,
matching: AlbumMeta,
matching: AlbumId,
item: M,
) -> Self {
let list = vec![item.into()];

View File

@ -231,7 +231,7 @@ impl JobInstance {
if let Some(params) = self.requests.front() {
let result_sender = &mut self.result_sender;
let paging = &mut self.paging;
Self::execute(musicbrainz, result_sender, event_sender, &params, paging)?;
Self::execute(musicbrainz, result_sender, event_sender, params, paging)?;
};
if self.paging.is_none() {
@ -263,7 +263,7 @@ impl JobInstance {
.map(|rv| EntityMatches::artist_lookup(p.artist.clone(), rv)),
LookupParams::ReleaseGroup(p) => {
musicbrainz.lookup_release_group(&p.mbid).map(|rv| {
EntityMatches::album_lookup(p.artist_id.clone(), p.album.clone(), rv)
EntityMatches::album_lookup(p.artist_id.clone(), p.album_id.clone(), rv)
})
}
}
@ -275,7 +275,7 @@ impl JobInstance {
SearchParams::ReleaseGroup(p) => musicbrainz
.search_release_group(&p.artist_mbid, &p.album)
.map(|rv| {
EntityMatches::album_search(p.artist_id.clone(), p.album.clone(), rv)
EntityMatches::album_search(p.artist_id.clone(), p.album.id.clone(), rv)
}),
}
.map(MbReturn::Match),
@ -428,9 +428,9 @@ mod tests {
fn lookup_release_group_requests() -> VecDeque<MbParams> {
let artist_id = COLLECTION[1].meta.id.clone();
let album = COLLECTION[1].albums[0].meta.clone();
let album_id = COLLECTION[1].albums[0].meta.id.clone();
let mbid = mbid();
VecDeque::from([MbParams::lookup_release_group(artist_id, album, mbid)])
VecDeque::from([MbParams::lookup_release_group(artist_id, album_id, mbid)])
}
fn search_artist_requests() -> VecDeque<MbParams> {
@ -630,8 +630,9 @@ mod tests {
fn execute_lookup_release_group() {
let mut musicbrainz = musicbrainz();
let mbid = mbid();
let album = COLLECTION[1].albums[0].meta.clone();
let lookup = Entity::new(album.clone());
let album_id = COLLECTION[1].albums[0].meta.id.clone();
let album_meta = COLLECTION[1].albums[0].meta.clone();
let lookup = Entity::new(album_meta.clone());
lookup_release_group_expectation(&mut musicbrainz, &mbid, &lookup);
let mut event_sender = event_sender();
@ -656,7 +657,7 @@ mod tests {
assert_eq!(
result,
Ok(MbReturn::Match(EntityMatches::album_lookup(
artist_id, album, lookup
artist_id, album_id, lookup
)))
);
}
@ -760,7 +761,7 @@ mod tests {
result,
Ok(MbReturn::Match(EntityMatches::album_search(
artist_id.clone(),
album_1,
album_1.id,
matches_1
)))
);
@ -770,7 +771,7 @@ mod tests {
result,
Ok(MbReturn::Match(EntityMatches::album_search(
artist_id.clone(),
album_4,
album_4.id,
matches_4
)))
);

View File

@ -1,7 +1,7 @@
use std::{collections::VecDeque, fmt, sync::mpsc};
use musichoard::collection::{
album::AlbumMeta,
album::{AlbumId, AlbumMeta},
artist::{ArtistId, ArtistMeta},
musicbrainz::Mbid,
};
@ -59,6 +59,7 @@ pub trait IMbJobSender {
pub enum MbParams {
Lookup(LookupParams),
Search(SearchParams),
#[allow(dead_code)] // TODO: remove with completion of #160
Browse(BrowseParams),
}
@ -77,7 +78,7 @@ pub struct LookupArtistParams {
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct LookupReleaseGroupParams {
pub artist_id: ArtistId,
pub album: AlbumMeta,
pub album_id: AlbumId,
pub mbid: Mbid,
}
@ -101,6 +102,7 @@ pub struct SearchReleaseGroupParams {
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum BrowseParams {
#[allow(dead_code)] // TODO: remove with completion of #160
ReleaseGroup(BrowseReleaseGroupParams),
}
@ -114,10 +116,10 @@ impl MbParams {
MbParams::Lookup(LookupParams::Artist(LookupArtistParams { artist, mbid }))
}
pub fn lookup_release_group(artist_id: ArtistId, album: AlbumMeta, mbid: Mbid) -> Self {
pub fn lookup_release_group(artist_id: ArtistId, album_id: AlbumId, mbid: Mbid) -> Self {
MbParams::Lookup(LookupParams::ReleaseGroup(LookupReleaseGroupParams {
artist_id,
album,
album_id,
mbid,
}))
}

View File

@ -20,9 +20,12 @@ pub trait IMusicHoard {
fn reload_database(&mut self) -> Result<(), musichoard::Error>;
fn get_collection(&self) -> &Collection;
fn set_artist_info(&mut self, id: &ArtistId, info: ArtistInfo)
-> Result<(), musichoard::Error>;
fn set_album_info(
fn merge_artist_info(
&mut self,
id: &ArtistId,
info: ArtistInfo,
) -> Result<(), musichoard::Error>;
fn merge_album_info(
&mut self,
artist_id: &ArtistId,
album_id: &AlbumId,
@ -44,21 +47,21 @@ impl<Database: IDatabase, Library: ILibrary> IMusicHoard for MusicHoard<Database
<Self as IMusicHoardBase>::get_collection(self)
}
fn set_artist_info(
fn merge_artist_info(
&mut self,
id: &ArtistId,
info: ArtistInfo,
) -> Result<(), musichoard::Error> {
<Self as IMusicHoardDatabase>::set_artist_info(self, id, info)
<Self as IMusicHoardDatabase>::merge_artist_info(self, id, info)
}
fn set_album_info(
fn merge_album_info(
&mut self,
artist_id: &ArtistId,
album_id: &AlbumId,
info: AlbumInfo,
) -> Result<(), musichoard::Error> {
<Self as IMusicHoardDatabase>::set_album_info(self, artist_id, album_id, info)
<Self as IMusicHoardDatabase>::merge_album_info(self, artist_id, album_id, info)
}
}
// GRCOV_EXCL_STOP

View File

@ -1,5 +1,7 @@
use musichoard::collection::{
album::{AlbumDate, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType, AlbumSeq, AlbumStatus},
album::{
AlbumDate, AlbumId, AlbumMeta, AlbumPrimaryType, AlbumSecondaryType, AlbumSeq, AlbumStatus,
},
artist::ArtistMeta,
musicbrainz::{IMusicBrainzRef, MbRefOption},
track::{TrackFormat, TrackQuality},
@ -111,12 +113,8 @@ impl UiDisplay {
format!("Matching artist: {}", &artist.id.name)
}
pub fn display_album_matching(album: &AlbumMeta) -> String {
format!(
"Matching album: {} | {}",
UiDisplay::display_album_date(&album.date),
&album.id.title
)
pub fn display_album_matching(album: &AlbumId) -> String {
format!("Matching album: {}", &album.title)
}
pub fn display_matching_info(info: &EntityMatches) -> String {

View File

@ -1,4 +1,7 @@
use musichoard::collection::{album::AlbumMeta, artist::ArtistMeta};
use musichoard::collection::{
album::{AlbumId, AlbumMeta},
artist::ArtistMeta,
};
use ratatui::widgets::{List, ListItem};
use crate::tui::{
@ -37,7 +40,7 @@ impl<'a, 'b> MatchOverlay<'a, 'b> {
}
fn albums(
matching: &AlbumMeta,
matching: &AlbumId,
matches: &'a [MatchOption<AlbumMeta>],
state: &'b mut WidgetState,
) -> Self {

View File

@ -356,9 +356,13 @@ mod tests {
ArtistId::new("Artist")
}
fn album_meta() -> AlbumMeta {
fn album_id() -> AlbumId {
AlbumId::new("An Album")
}
fn album_meta(id: AlbumId) -> AlbumMeta {
AlbumMeta::new(
AlbumId::new("An Album"),
id,
AlbumDate::new(Some(1990), Some(5), None),
AlbumInfo::new(
MbRefOption::None,
@ -370,11 +374,12 @@ mod tests {
fn album_matches() -> EntityMatches {
let artist_id = album_artist_id();
let album = album_meta();
let album_match = Entity::with_score(album.clone(), 80);
let album_id = album_id();
let album_meta = album_meta(album_id.clone());
let album_match = Entity::with_score(album_meta.clone(), 80);
let list = vec![album_match.clone(), album_match.clone()];
let mut info = EntityMatches::album_search(artist_id, album, list);
let mut info = EntityMatches::album_search(artist_id, album_id, list);
info.push_cannot_have_mbid();
info.push_manual_input_mbid();
info
@ -382,10 +387,11 @@ mod tests {
fn album_lookup() -> EntityMatches {
let artist_id = album_artist_id();
let album = album_meta();
let album_lookup = Entity::new(album.clone());
let album_id = album_id();
let album_meta = album_meta(album_id.clone());
let album_lookup = Entity::new(album_meta.clone());
let mut info = EntityMatches::album_lookup(artist_id, album, album_lookup);
let mut info = EntityMatches::album_lookup(artist_id, album_id, album_lookup);
info.push_cannot_have_mbid();
info.push_manual_input_mbid();
info