diff --git a/src/tui/app/machine/fetch_state.rs b/src/tui/app/machine/fetch_state.rs index 412c9f1..55eb380 100644 --- a/src/tui/app/machine/fetch_state.rs +++ b/src/tui/app/machine/fetch_state.rs @@ -365,7 +365,7 @@ impl IAppEventFetch for AppMachine { #[cfg(test)] mod tests { - use mockall::predicate; + use mockall::{predicate, Sequence}; use musichoard::collection::{ album::AlbumMeta, artist::{ArtistId, ArtistMeta}, @@ -739,11 +739,18 @@ mod tests { tx.send(fetch_result).unwrap(); drop(tx); - let mut music_hoard = music_hoard(collection); + let mut music_hoard = music_hoard(collection.clone()); + let mut seq = Sequence::new(); + music_hoard + .expect_get_collection() + .times(1) + .in_sequence(&mut seq) + .return_const(collection); music_hoard .expect_add_album() .with(predicate::eq(artist_id), predicate::eq(new_album)) .times(1) + .in_sequence(&mut seq) .return_once(|_, _| Ok(())); let app = AppMachine::app_fetch_next(inner(music_hoard), fetch); @@ -766,11 +773,18 @@ mod tests { tx.send(fetch_result).unwrap(); drop(tx); - let mut music_hoard = music_hoard(collection); + let mut music_hoard = music_hoard(collection.clone()); + let mut seq = Sequence::new(); + music_hoard + .expect_get_collection() + .times(1) + .in_sequence(&mut seq) + .return_const(collection); music_hoard .expect_add_album() .with(predicate::eq(artist_id), predicate::eq(new_album)) .times(1) + .in_sequence(&mut seq) .return_once(|_, _| Err(musichoard::Error::CollectionError(String::from("get rekt")))); let app = AppMachine::app_fetch_next(inner(music_hoard), fetch); diff --git a/src/tui/app/machine/match_state.rs b/src/tui/app/machine/match_state.rs index 17eec10..4c8e83c 100644 --- a/src/tui/app/machine/match_state.rs +++ b/src/tui/app/machine/match_state.rs @@ -447,7 +447,8 @@ mod tests { let (_tx, rx) = mpsc::channel(); let app_matches = MatchState::new(matches_info.clone(), FetchState::search(rx)); - let mut music_hoard = music_hoard(vec![]); + let collection = vec![]; + let mut music_hoard = music_hoard(collection.clone()); let artist_id = ArtistId::new("Artist"); match matches_info { EntityMatches::Album(_) => { @@ -456,6 +457,11 @@ mod tests { let info = AlbumInfo::default(); let mut seq = Sequence::new(); + music_hoard + .expect_get_collection() + .times(1) + .in_sequence(&mut seq) + .return_const(collection); music_hoard .expect_merge_album_info() .with(eq(artist_id.clone()), eq(album_id.clone()), eq(info)) @@ -595,7 +601,8 @@ mod tests { let (_tx, rx) = mpsc::channel(); let app_matches = MatchState::new(matches_info.clone(), FetchState::search(rx)); - let mut music_hoard = music_hoard(vec![]); + let collection = vec![]; + let mut music_hoard = music_hoard(collection.clone()); match matches_info { EntityMatches::Artist(_) => panic!(), EntityMatches::Album(matches) => { @@ -606,6 +613,11 @@ mod tests { let artist = matches.artist.clone(); let mut seq = Sequence::new(); + music_hoard + .expect_get_collection() + .times(1) + .in_sequence(&mut seq) + .return_const(collection); music_hoard .expect_merge_album_info() .with(eq(artist.clone()), eq(album_id.clone()), eq(meta.info)) @@ -647,13 +659,19 @@ mod tests { let (_tx, rx) = mpsc::channel(); let app_matches = MatchState::new(matches_info.clone(), FetchState::search(rx)); - let mut music_hoard = music_hoard(vec![artist]); + let collection = vec![artist]; + let mut music_hoard = music_hoard(collection.clone()); match matches_info { EntityMatches::Artist(_) => panic!(), EntityMatches::Album(matches) => { let artist = matches.artist.clone(); let mut seq = Sequence::new(); + music_hoard + .expect_get_collection() + .times(1) + .in_sequence(&mut seq) + .return_const(collection); music_hoard .expect_remove_album() .times(1)