Make MBID part of the album identifier to disambiguate MB clashes #240

Merged
wojtek merged 4 commits from 231---differentiate-release-groups-with-same-title-but-different-type-clash into main 2025-01-02 19:53:39 +01:00
Showing only changes of commit 5da84a2431 - Show all commits

View File

@ -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]