Compare commits
2 Commits
5abac79414
...
17d94e59f1
Author | SHA1 | Date | |
---|---|---|---|
17d94e59f1 | |||
dd9141352c |
@ -48,8 +48,12 @@ pub enum MbRefOption<T> {
|
||||
impl<T> MbRefOption<T> {
|
||||
pub fn or(self, optb: MbRefOption<T>) -> MbRefOption<T> {
|
||||
match self {
|
||||
x @ MbRefOption::Some(_) => x,
|
||||
MbRefOption::CannotHaveMbid | MbRefOption::None => optb,
|
||||
opta @ MbRefOption::Some(_) => opta,
|
||||
opta @ MbRefOption::CannotHaveMbid => match optb {
|
||||
MbRefOption::Some(_) => optb,
|
||||
MbRefOption::CannotHaveMbid | MbRefOption::None => opta,
|
||||
},
|
||||
MbRefOption::None => optb,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -395,8 +395,10 @@ mod tests {
|
||||
match matches_info {
|
||||
EntityMatches::Album(_) => {
|
||||
let album_id = AlbumId::new("Album");
|
||||
let mut info = album_meta(album_id.clone()).info;
|
||||
info.musicbrainz = MbRefOption::CannotHaveMbid;
|
||||
let info = AlbumInfo {
|
||||
musicbrainz: MbRefOption::CannotHaveMbid,
|
||||
..Default::default()
|
||||
};
|
||||
music_hoard
|
||||
.expect_merge_album_info()
|
||||
.with(eq(artist_id.clone()), eq(album_id.clone()), eq(info))
|
||||
@ -404,8 +406,10 @@ mod tests {
|
||||
.return_once(|_, _, _| Ok(()));
|
||||
}
|
||||
EntityMatches::Artist(_) => {
|
||||
let mut info = artist_meta().info;
|
||||
info.musicbrainz = MbRefOption::CannotHaveMbid;
|
||||
let info = ArtistInfo {
|
||||
musicbrainz: MbRefOption::CannotHaveMbid,
|
||||
..Default::default()
|
||||
};
|
||||
music_hoard
|
||||
.expect_merge_artist_info()
|
||||
.with(eq(artist_id.clone()), eq(info))
|
||||
|
39
src/tui/lib/external/musicbrainz/daemon/mod.rs
vendored
39
src/tui/lib/external/musicbrainz/daemon/mod.rs
vendored
@ -252,10 +252,6 @@ 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
|
||||
@ -280,15 +276,24 @@ impl JobInstance {
|
||||
}
|
||||
.map(MbReturn::Match),
|
||||
MbParams::Browse(browse) => match browse {
|
||||
BrowseParams::ReleaseGroup(params) => musicbrainz
|
||||
.browse_release_group(¶ms.artist, paging)
|
||||
.map(|rv| EntityList::Album(rv.into_iter().map(|rg| rg.entity).collect())),
|
||||
BrowseParams::ReleaseGroup(params) => {
|
||||
Self::init_paging_if_none(paging);
|
||||
musicbrainz
|
||||
.browse_release_group(¶ms.artist, paging)
|
||||
.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,
|
||||
@ -757,24 +762,12 @@ mod tests {
|
||||
let artist_id = album_artist_id();
|
||||
|
||||
let result = result_receiver.try_recv().unwrap();
|
||||
assert_eq!(
|
||||
result,
|
||||
Ok(MbReturn::Match(EntityMatches::album_search(
|
||||
artist_id.clone(),
|
||||
album_1.id,
|
||||
matches_1
|
||||
)))
|
||||
);
|
||||
let matches = EntityMatches::album_search(artist_id.clone(), album_1.id, matches_1);
|
||||
assert_eq!(result, Ok(MbReturn::Match(matches)));
|
||||
|
||||
let result = result_receiver.try_recv().unwrap();
|
||||
assert_eq!(
|
||||
result,
|
||||
Ok(MbReturn::Match(EntityMatches::album_search(
|
||||
artist_id.clone(),
|
||||
album_4.id,
|
||||
matches_4
|
||||
)))
|
||||
);
|
||||
let matches = EntityMatches::album_search(artist_id.clone(), album_4.id, matches_4);
|
||||
assert_eq!(result, Ok(MbReturn::Match(matches)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user