Slightly compress UT code
All checks were successful
Cargo CI / Build and Test (pull_request) Successful in 1m57s
Cargo CI / Lint (pull_request) Successful in 1m8s

This commit is contained in:
Wojciech Kozlowski 2025-01-02 19:50:07 +01:00
parent 00648063e2
commit 5da84a2431

View File

@ -764,28 +764,22 @@ mod tests {
database.expect_save().times(2).returning(|_| Ok(())); database.expect_save().times(2).returning(|_| Ok(()));
let mut music_hoard = MusicHoard::database(database).unwrap(); let mut music_hoard = MusicHoard::database(database).unwrap();
assert_eq!( let album = &music_hoard.collection[0].albums[0];
music_hoard.collection[0].albums[0].meta.id.db_id, assert_eq!(album.meta.id.db_id, AlbumDbId::None);
AlbumDbId::None
);
// Seting db_id on an album not belonging to the artist is an error. // Seting db_id on an album not belonging to the artist is an error.
assert!(music_hoard assert!(music_hoard
.set_album_db_id(&artist_id, &album_id_2, AlbumDbId::CannotHaveMbid) .set_album_db_id(&artist_id, &album_id_2, AlbumDbId::CannotHaveMbid)
.is_err()); .is_err());
assert_eq!( let album = &music_hoard.collection[0].albums[0];
music_hoard.collection[0].albums[0].meta.id.db_id, assert_eq!(album.meta.id.db_id, AlbumDbId::None);
AlbumDbId::None
);
// Set db_id. // Set db_id.
assert!(music_hoard assert!(music_hoard
.set_album_db_id(&artist_id, &album_id, AlbumDbId::CannotHaveMbid) .set_album_db_id(&artist_id, &album_id, AlbumDbId::CannotHaveMbid)
.is_ok()); .is_ok());
assert_eq!( let album = &music_hoard.collection[0].albums[0];
music_hoard.collection[0].albums[0].meta.id.db_id, assert_eq!(album.meta.id.db_id, AlbumDbId::CannotHaveMbid);
AlbumDbId::CannotHaveMbid
);
// Clearing db_id on an album that does not exist is an error. // Clearing db_id on an album that does not exist is an error.
assert!(music_hoard assert!(music_hoard
@ -797,18 +791,14 @@ mod tests {
assert!(music_hoard assert!(music_hoard
.clear_album_db_id(&artist_id, &album_id) .clear_album_db_id(&artist_id, &album_id)
.is_err()); .is_err());
assert_eq!( let album = &music_hoard.collection[0].albums[0];
music_hoard.collection[0].albums[0].meta.id.db_id, assert_eq!(album.meta.id.db_id, AlbumDbId::CannotHaveMbid);
AlbumDbId::CannotHaveMbid
);
// To clear the db_id we need the album_id to have the db_id to identify the correct album. // 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); album_id.set_db_id(AlbumDbId::CannotHaveMbid);
assert!(music_hoard.clear_album_db_id(&artist_id, &album_id).is_ok()); assert!(music_hoard.clear_album_db_id(&artist_id, &album_id).is_ok());
assert_eq!( let album = &music_hoard.collection[0].albums[0];
music_hoard.collection[0].albums[0].meta.id.db_id, assert_eq!(album.meta.id.db_id, AlbumDbId::None);
AlbumDbId::None
);
} }
#[test] #[test]