Compare commits

..

No commits in common. "17d94e59f18295b60c74e9828412dcf044eb4f4e" and "5abac79414cd62e1a899cfa3dd8e1c4d3c35a6d0" have entirely different histories.

3 changed files with 29 additions and 30 deletions

View File

@ -48,12 +48,8 @@ pub enum MbRefOption<T> {
impl<T> MbRefOption<T> {
pub fn or(self, optb: MbRefOption<T>) -> MbRefOption<T> {
match self {
opta @ MbRefOption::Some(_) => opta,
opta @ MbRefOption::CannotHaveMbid => match optb {
MbRefOption::Some(_) => optb,
MbRefOption::CannotHaveMbid | MbRefOption::None => opta,
},
MbRefOption::None => optb,
x @ MbRefOption::Some(_) => x,
MbRefOption::CannotHaveMbid | MbRefOption::None => optb,
}
}

View File

@ -395,10 +395,8 @@ mod tests {
match matches_info {
EntityMatches::Album(_) => {
let album_id = AlbumId::new("Album");
let info = AlbumInfo {
musicbrainz: MbRefOption::CannotHaveMbid,
..Default::default()
};
let mut info = album_meta(album_id.clone()).info;
info.musicbrainz = MbRefOption::CannotHaveMbid;
music_hoard
.expect_merge_album_info()
.with(eq(artist_id.clone()), eq(album_id.clone()), eq(info))
@ -406,10 +404,8 @@ mod tests {
.return_once(|_, _, _| Ok(()));
}
EntityMatches::Artist(_) => {
let info = ArtistInfo {
musicbrainz: MbRefOption::CannotHaveMbid,
..Default::default()
};
let mut info = artist_meta().info;
info.musicbrainz = MbRefOption::CannotHaveMbid;
music_hoard
.expect_merge_artist_info()
.with(eq(artist_id.clone()), eq(info))

View File

@ -252,6 +252,10 @@ impl JobInstance {
api_params: &MbParams,
paging: &mut Option<PageSettings>,
) -> Result<(), JobInstanceError> {
if paging.is_none() {
*paging = Some(PageSettings::with_max_limit());
}
let result = match api_params {
MbParams::Lookup(lookup) => match lookup {
LookupParams::Artist(p) => musicbrainz
@ -276,24 +280,15 @@ impl JobInstance {
}
.map(MbReturn::Match),
MbParams::Browse(browse) => match browse {
BrowseParams::ReleaseGroup(params) => {
Self::init_paging_if_none(paging);
musicbrainz
BrowseParams::ReleaseGroup(params) => musicbrainz
.browse_release_group(&params.artist, paging)
.map(|rv| EntityList::Album(rv.into_iter().map(|rg| rg.entity).collect()))
}
.map(|rv| EntityList::Album(rv.into_iter().map(|rg| rg.entity).collect())),
}
.map(MbReturn::Fetch),
};
Self::return_result(result_sender, event_sender, result)
}
fn init_paging_if_none(paging: &mut Option<PageSettings>) {
if paging.is_none() {
*paging = Some(PageSettings::with_max_limit());
}
}
fn return_result(
result_sender: &mut ResultSender,
event_sender: &mut dyn IFetchCompleteEventSender,
@ -762,12 +757,24 @@ mod tests {
let artist_id = album_artist_id();
let result = result_receiver.try_recv().unwrap();
let matches = EntityMatches::album_search(artist_id.clone(), album_1.id, matches_1);
assert_eq!(result, Ok(MbReturn::Match(matches)));
assert_eq!(
result,
Ok(MbReturn::Match(EntityMatches::album_search(
artist_id.clone(),
album_1.id,
matches_1
)))
);
let result = result_receiver.try_recv().unwrap();
let matches = EntityMatches::album_search(artist_id.clone(), album_4.id, matches_4);
assert_eq!(result, Ok(MbReturn::Match(matches)));
assert_eq!(
result,
Ok(MbReturn::Match(EntityMatches::album_search(
artist_id.clone(),
album_4.id,
matches_4
)))
);
}
#[test]