Provide a keyboard shortcut to pull all release groups of an artist #233
@ -156,16 +156,6 @@ impl Album {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn with_type<Id: Into<AlbumId>, Date: Into<AlbumDate>>(
|
||||
mut self,
|
||||
primary_type: Option<AlbumPrimaryType>,
|
||||
secondary_types: Vec<AlbumSecondaryType>,
|
||||
) -> Self {
|
||||
self.meta.info.primary_type = primary_type;
|
||||
self.meta.info.secondary_types = secondary_types;
|
||||
self
|
||||
}
|
||||
|
||||
pub fn get_status(&self) -> AlbumStatus {
|
||||
AlbumStatus::from_tracks(&self.tracks)
|
||||
}
|
||||
|
@ -680,7 +680,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recv_ok_fetch_ok() {
|
||||
fn recv_ok_match_ok() {
|
||||
let (tx, rx) = mpsc::channel::<MbApiResult>();
|
||||
|
||||
let artist = COLLECTION[3].meta.clone();
|
||||
@ -707,7 +707,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recv_ok_fetch_err() {
|
||||
fn recv_ok_search_err() {
|
||||
let (tx, rx) = mpsc::channel::<MbApiResult>();
|
||||
|
||||
let fetch_result = Err(musicbrainz::api::Error::RateLimit);
|
||||
@ -719,6 +719,60 @@ mod tests {
|
||||
assert!(matches!(app, AppState::Error(_)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recv_ok_fetch_ok() {
|
||||
let collection = COLLECTION.clone();
|
||||
|
||||
let (tx, rx) = mpsc::channel::<MbApiResult>();
|
||||
let fetch = FetchState::fetch(rx);
|
||||
|
||||
let artist_id = collection[0].meta.id.clone();
|
||||
let old_album = collection[0].albums[0].meta.clone();
|
||||
let new_album = AlbumMeta::new(AlbumId::new("some new album"));
|
||||
|
||||
let release_group_fetch = EntityList::Album(vec![old_album.clone(), new_album.clone()]);
|
||||
let fetch_result = Ok(MbReturn::Fetch(release_group_fetch));
|
||||
tx.send(fetch_result).unwrap();
|
||||
drop(tx);
|
||||
|
||||
let mut music_hoard = music_hoard(collection);
|
||||
music_hoard
|
||||
.expect_add_album()
|
||||
.with(predicate::eq(artist_id), predicate::eq(new_album))
|
||||
.times(1)
|
||||
.return_once(|_, _| Ok(()));
|
||||
|
||||
let app = AppMachine::app_fetch_next(inner(music_hoard), fetch);
|
||||
assert!(matches!(app, AppState::Browse(_)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recv_ok_fetch_ok_add_album_err() {
|
||||
let collection = COLLECTION.clone();
|
||||
|
||||
let (tx, rx) = mpsc::channel::<MbApiResult>();
|
||||
let fetch = FetchState::fetch(rx);
|
||||
|
||||
let artist_id = collection[0].meta.id.clone();
|
||||
let old_album = collection[0].albums[0].meta.clone();
|
||||
let new_album = AlbumMeta::new(AlbumId::new("some new album"));
|
||||
|
||||
let release_group_fetch = EntityList::Album(vec![old_album.clone(), new_album.clone()]);
|
||||
let fetch_result = Ok(MbReturn::Fetch(release_group_fetch));
|
||||
tx.send(fetch_result).unwrap();
|
||||
drop(tx);
|
||||
|
||||
let mut music_hoard = music_hoard(collection);
|
||||
music_hoard
|
||||
.expect_add_album()
|
||||
.with(predicate::eq(artist_id), predicate::eq(new_album))
|
||||
.times(1)
|
||||
.return_once(|_, _| Err(musichoard::Error::CollectionError(String::from("get rekt"))));
|
||||
|
||||
let app = AppMachine::app_fetch_next(inner(music_hoard), fetch);
|
||||
assert!(matches!(app, AppState::Error(_)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recv_err_empty() {
|
||||
let (_tx, rx) = mpsc::channel::<MbApiResult>();
|
||||
@ -764,7 +818,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn recv_err_disconnected_next() {
|
||||
fn recv_err_disconnected_search_next() {
|
||||
let mut collection = COLLECTION.clone();
|
||||
collection[0].albums.clear();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user