From 9c126461fcaea9e85bfc37fbc1b9d39539ec5553 Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Fri, 12 Jan 2024 20:38:42 +0100 Subject: [PATCH] Fix code coverage --- src/lib.rs | 64 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 760bc34..4002b47 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1111,7 +1111,7 @@ mod tests { fn artist_new_delete() { let artist_id = ArtistId::new("an artist"); let artist_id_2 = ArtistId::new("another artist"); - let mut music_hoard = MusicHoardBuilder::new().build(); + let mut music_hoard = MusicHoardBuilder::default().build(); let mut expected: Vec = vec![]; @@ -1133,7 +1133,7 @@ mod tests { #[test] fn collection_error() { let artist_id = ArtistId::new("an artist"); - let mut music_hoard = MusicHoardBuilder::new().build(); + let mut music_hoard = MusicHoardBuilder::default().build(); let actual_err = music_hoard .add_musicbrainz_url(&artist_id, QOBUZ) @@ -1148,7 +1148,7 @@ mod tests { fn add_remove_musicbrainz_url() { let artist_id = ArtistId::new("an artist"); let artist_id_2 = ArtistId::new("another artist"); - let mut music_hoard = MusicHoardBuilder::new().build(); + let mut music_hoard = MusicHoardBuilder::default().build(); music_hoard.add_artist(artist_id.clone()); @@ -1219,7 +1219,7 @@ mod tests { fn set_clear_musicbrainz_url() { let artist_id = ArtistId::new("an artist"); let artist_id_2 = ArtistId::new("another artist"); - let mut music_hoard = MusicHoardBuilder::new().build(); + let mut music_hoard = MusicHoardBuilder::default().build(); music_hoard.add_artist(artist_id.clone()); @@ -1274,7 +1274,7 @@ mod tests { fn add_remove_musicbutler_urls() { let artist_id = ArtistId::new("an artist"); let artist_id_2 = ArtistId::new("another artist"); - let mut music_hoard = MusicHoardBuilder::new().build(); + let mut music_hoard = MusicHoardBuilder::default().build(); music_hoard.add_artist(artist_id.clone()); @@ -1404,7 +1404,7 @@ mod tests { fn set_clear_musicbutler_urls() { let artist_id = ArtistId::new("an artist"); let artist_id_2 = ArtistId::new("another artist"); - let mut music_hoard = MusicHoardBuilder::new().build(); + let mut music_hoard = MusicHoardBuilder::default().build(); music_hoard.add_artist(artist_id.clone()); @@ -1467,7 +1467,7 @@ mod tests { fn add_remove_bandcamp_urls() { let artist_id = ArtistId::new("an artist"); let artist_id_2 = ArtistId::new("another artist"); - let mut music_hoard = MusicHoardBuilder::new().build(); + let mut music_hoard = MusicHoardBuilder::default().build(); music_hoard.add_artist(artist_id.clone()); @@ -1597,7 +1597,7 @@ mod tests { fn set_clear_bandcamp_urls() { let artist_id = ArtistId::new("an artist"); let artist_id_2 = ArtistId::new("another artist"); - let mut music_hoard = MusicHoardBuilder::new().build(); + let mut music_hoard = MusicHoardBuilder::default().build(); music_hoard.add_artist(artist_id.clone()); @@ -1660,7 +1660,7 @@ mod tests { fn add_remove_qobuz_url() { let artist_id = ArtistId::new("an artist"); let artist_id_2 = ArtistId::new("another artist"); - let mut music_hoard = MusicHoardBuilder::new().build(); + let mut music_hoard = MusicHoardBuilder::default().build(); music_hoard.add_artist(artist_id.clone()); @@ -1711,7 +1711,7 @@ mod tests { fn set_clear_qobuz_url() { let artist_id = ArtistId::new("an artist"); let artist_id_2 = ArtistId::new("another artist"); - let mut music_hoard = MusicHoardBuilder::new().build(); + let mut music_hoard = MusicHoardBuilder::default().build(); music_hoard.add_artist(artist_id.clone()); @@ -1850,7 +1850,7 @@ mod tests { let mut expected = COLLECTION.to_owned(); expected.sort_unstable(); - let merged = MusicHoard::::merge(left.clone(), right); + let merged = MusicHoard::::merge(left.clone(), right); assert_eq!(expected, merged); } @@ -1864,7 +1864,7 @@ mod tests { let mut expected = COLLECTION.to_owned(); expected.sort_unstable(); - let merged = MusicHoard::::merge(left.clone(), right); + let merged = MusicHoard::::merge(left.clone(), right); assert_eq!(expected, merged); } @@ -1882,7 +1882,10 @@ mod tests { .times(1) .return_once(|_| library_result); - let mut music_hoard = MusicHoard::new(library, database); + let mut music_hoard = MusicHoardBuilder::default() + .set_library(library) + .set_database(database) + .build(); music_hoard.rescan_library().unwrap(); assert_eq!( @@ -1909,7 +1912,10 @@ mod tests { .times(1) .return_once(|_| library_result); - let mut music_hoard = MusicHoard::new(library, database); + let mut music_hoard = MusicHoardBuilder::default() + .set_library(library) + .set_database(database) + .build(); music_hoard.rescan_library().unwrap(); assert_eq!( @@ -1936,7 +1942,10 @@ mod tests { .times(1) .return_once(|_| library_result); - let mut music_hoard = MusicHoard::new(library, database); + let mut music_hoard = MusicHoardBuilder::default() + .set_library(library) + .set_database(database) + .build(); music_hoard.rescan_library().unwrap(); assert_eq!(music_hoard.get_collection(), &expected); @@ -1955,7 +1964,10 @@ mod tests { Ok(()) }); - let mut music_hoard = MusicHoard::new(library, database); + let mut music_hoard = MusicHoardBuilder::default() + .set_library(library) + .set_database(database) + .build(); music_hoard.load_from_database().unwrap(); assert_eq!(music_hoard.get_collection(), &*COLLECTION); @@ -1984,7 +1996,10 @@ mod tests { .times(1) .return_once(|_: &Collection| database_result); - let mut music_hoard = MusicHoard::new(library, database); + let mut music_hoard = MusicHoardBuilder::default() + .set_library(library) + .set_database(database) + .build(); music_hoard.rescan_library().unwrap(); assert_eq!( @@ -2006,7 +2021,10 @@ mod tests { .times(1) .return_once(|_| library_result); - let mut music_hoard = MusicHoard::new(library, database); + let mut music_hoard = MusicHoardBuilder::default() + .set_library(library) + .set_database(database) + .build(); let actual_err = music_hoard.rescan_library().unwrap_err(); let expected_err = @@ -2028,7 +2046,10 @@ mod tests { .times(1) .return_once(|_: &mut Collection| database_result); - let mut music_hoard = MusicHoard::new(library, database); + let mut music_hoard = MusicHoardBuilder::default() + .set_library(library) + .set_database(database) + .build(); let actual_err = music_hoard.load_from_database().unwrap_err(); let expected_err = Error::DatabaseError( @@ -2051,7 +2072,10 @@ mod tests { .times(1) .return_once(|_: &Collection| database_result); - let mut music_hoard = MusicHoard::new(library, database); + let mut music_hoard = MusicHoardBuilder::default() + .set_library(library) + .set_database(database) + .build(); let actual_err = music_hoard.save_to_database().unwrap_err(); let expected_err = Error::DatabaseError(