From f4f0da45fe8c4b31c87c2d9c31920ecfc066f7cd Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Mon, 30 Dec 2024 20:17:53 +0100 Subject: [PATCH] Fix unit tests --- src/tui/app/machine/fetch_state.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/tui/app/machine/fetch_state.rs b/src/tui/app/machine/fetch_state.rs index f10e15a..12fac9e 100644 --- a/src/tui/app/machine/fetch_state.rs +++ b/src/tui/app/machine/fetch_state.rs @@ -370,7 +370,7 @@ mod tests { use crate::tui::{ app::{ - machine::tests::{inner, music_hoard}, + machine::tests::{inner, inner_with_mb, music_hoard}, Delta, EntityMatches, IApp, IAppAccess, IAppInteractBrowse, MatchOption, }, lib::interface::musicbrainz::{self, api::Entity, daemon::MockIMbJobSender}, @@ -734,8 +734,18 @@ mod tests { let mut collection = COLLECTION.clone(); collection[0].albums.clear(); - let app = AppMachine::app_fetch_first(inner(music_hoard(collection))); - assert!(matches!(app, AppState::Browse(_))); + let requests = AppMachine::browse_release_group_job(&collection[0].meta.info.musicbrainz); + + let mut mb_job_sender = MockIMbJobSender::new(); + mb_job_sender + .expect_submit_background_job() + .with(predicate::always(), predicate::eq(requests)) + .times(1) + .return_once(|_, _| Ok(())); + + let inner = inner_with_mb(music_hoard(collection), mb_job_sender); + let app = AppMachine::app_fetch_first(inner); + assert!(matches!(app, AppState::Fetch(_))); } #[test] @@ -743,11 +753,11 @@ mod tests { let mut collection = COLLECTION.clone(); collection[0].albums.clear(); - let (_, rx) = mpsc::channel::(); + let (_tx, rx) = mpsc::channel::(); let fetch = FetchState::search(rx); let app = AppMachine::app_fetch_next(inner(music_hoard(collection)), fetch); - assert!(matches!(app, AppState::Browse(_))); + assert!(matches!(app, AppState::Fetch(_))); } #[test]