diff --git a/src/core/collection/artist.rs b/src/core/collection/artist.rs index 3375ade..396561b 100644 --- a/src/core/collection/artist.rs +++ b/src/core/collection/artist.rs @@ -526,11 +526,20 @@ mod tests { let mut left = FULL_COLLECTION[0].to_owned(); let mut right = FULL_COLLECTION[1].to_owned(); right.meta.id = left.meta.id.clone(); + + // The right collection needs more albums than we modify to make sure some do not overlap. + assert!(right.albums.len() > 2); + + // This album will have a lib_id and will match based on lib_id. left.albums.push(right.albums[0].clone()); - left.albums.sort_unstable(); + + // This album will not have a lib_id and will match based on title. + left.albums.push(right.albums[1].clone()); + right.albums[1].meta.id.lib_id = AlbumLibId::None; // Albums on right without a match on the left will lose their lib id. - reset_lib_id(&mut right.albums[1..]); + let mut newly_added = right.albums[2..].to_vec(); + reset_lib_id(&mut newly_added); let mut expected = left.clone(); expected.meta.info.properties = expected @@ -538,9 +547,12 @@ mod tests { .info .properties .merge(right.clone().meta.info.properties); - expected.albums.append(&mut right.albums.clone()); + expected.albums.extend(newly_added); expected.albums.sort_unstable(); - expected.albums.dedup(); + + // Albums are expected to be sorted. + left.albums.sort_unstable(); + right.albums.sort_unstable(); let merged = left.clone().merge(right); assert_eq!(expected, merged);