From 5da84a243105a44cafe9813d9ff5a5dad22adff7 Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Thu, 2 Jan 2025 19:50:07 +0100 Subject: [PATCH] Slightly compress UT code --- src/core/musichoard/database.rs | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/src/core/musichoard/database.rs b/src/core/musichoard/database.rs index 52b35b9..6f7c563 100644 --- a/src/core/musichoard/database.rs +++ b/src/core/musichoard/database.rs @@ -764,28 +764,22 @@ mod tests { database.expect_save().times(2).returning(|_| Ok(())); let mut music_hoard = MusicHoard::database(database).unwrap(); - assert_eq!( - music_hoard.collection[0].albums[0].meta.id.db_id, - AlbumDbId::None - ); + let album = &music_hoard.collection[0].albums[0]; + assert_eq!(album.meta.id.db_id, AlbumDbId::None); // Seting db_id on an album not belonging to the artist is an error. assert!(music_hoard .set_album_db_id(&artist_id, &album_id_2, AlbumDbId::CannotHaveMbid) .is_err()); - assert_eq!( - music_hoard.collection[0].albums[0].meta.id.db_id, - AlbumDbId::None - ); + let album = &music_hoard.collection[0].albums[0]; + assert_eq!(album.meta.id.db_id, AlbumDbId::None); // Set db_id. assert!(music_hoard .set_album_db_id(&artist_id, &album_id, AlbumDbId::CannotHaveMbid) .is_ok()); - assert_eq!( - music_hoard.collection[0].albums[0].meta.id.db_id, - AlbumDbId::CannotHaveMbid - ); + let album = &music_hoard.collection[0].albums[0]; + assert_eq!(album.meta.id.db_id, AlbumDbId::CannotHaveMbid); // Clearing db_id on an album that does not exist is an error. assert!(music_hoard @@ -797,18 +791,14 @@ mod tests { assert!(music_hoard .clear_album_db_id(&artist_id, &album_id) .is_err()); - assert_eq!( - music_hoard.collection[0].albums[0].meta.id.db_id, - AlbumDbId::CannotHaveMbid - ); + let album = &music_hoard.collection[0].albums[0]; + assert_eq!(album.meta.id.db_id, AlbumDbId::CannotHaveMbid); // To clear the db_id we need the album_id to have the db_id to identify the correct album. album_id.set_db_id(AlbumDbId::CannotHaveMbid); assert!(music_hoard.clear_album_db_id(&artist_id, &album_id).is_ok()); - assert_eq!( - music_hoard.collection[0].albums[0].meta.id.db_id, - AlbumDbId::None - ); + let album = &music_hoard.collection[0].albums[0]; + assert_eq!(album.meta.id.db_id, AlbumDbId::None); } #[test]