Fix unit tests
Some checks failed
Cargo CI / Build and Test (pull_request) Failing after 2m35s
Cargo CI / Lint (pull_request) Failing after 33s

This commit is contained in:
Wojciech Kozlowski 2024-09-29 09:08:25 +02:00
parent 967c4b4175
commit 9488464b11

View File

@ -350,7 +350,7 @@ mod tests {
let app = browse.increment_selection(Delta::Line); let app = browse.increment_selection(Delta::Line);
let app = app.unwrap_browse().fetch_musicbrainz(); let app = app.unwrap_browse().fetch_musicbrainz();
assert!(matches!(app, AppState::Match(_))); assert!(matches!(app, AppState::Fetch(_)));
} }
fn lookup_album_expectation( fn lookup_album_expectation(
@ -413,7 +413,7 @@ mod tests {
let app = browse.increment_selection(Delta::Line); let app = browse.increment_selection(Delta::Line);
let app = app.unwrap_browse().fetch_musicbrainz(); let app = app.unwrap_browse().fetch_musicbrainz();
assert!(matches!(app, AppState::Match(_))); assert!(matches!(app, AppState::Fetch(_)));
} }
fn lookup_artist_expectation(job_sender: &mut MockIMbJobSender, artist: &ArtistMeta) { fn lookup_artist_expectation(job_sender: &mut MockIMbJobSender, artist: &ArtistMeta) {
@ -542,21 +542,23 @@ mod tests {
} }
#[test] #[test]
fn recv_err_disconnected_first() { fn recv_err_empty_first() {
let (_, rx) = mpsc::channel::<MbApiResult>(); let mut collection = COLLECTION.clone();
collection[0].albums.clear();
let inner = inner(music_hoard(COLLECTION.clone())); let app = AppMachine::app_fetch_first(inner(music_hoard(collection)));
let fetch = FetchState::new(rx);
let app = AppMachine::app_fetch_next(inner, fetch);
assert!(matches!(app, AppState::Match(_))); assert!(matches!(app, AppState::Match(_)));
} }
#[test] #[test]
fn recv_err_disconnected_next() { fn recv_err_empty_next() {
let (_, rx) = mpsc::channel::<MbApiResult>(); let mut collection = COLLECTION.clone();
collection[0].albums.clear();
let (_, rx) = mpsc::channel::<MbApiResult>();
let fetch = FetchState::new(rx); let fetch = FetchState::new(rx);
let app = AppMachine::app_fetch_next(inner(music_hoard(COLLECTION.clone())), fetch);
let app = AppMachine::app_fetch_next(inner(music_hoard(collection)), fetch);
assert!(matches!(app, AppState::Browse(_))); assert!(matches!(app, AppState::Browse(_)));
} }