Complete coverage
All checks were successful
Cargo CI / Build and Test (pull_request) Successful in 2m0s
Cargo CI / Lint (pull_request) Successful in 1m4s

This commit is contained in:
Wojciech Kozlowski 2025-01-02 13:07:21 +01:00
parent e0c6788125
commit 02fb023ad1

View File

@ -526,11 +526,20 @@ mod tests {
let mut left = FULL_COLLECTION[0].to_owned(); let mut left = FULL_COLLECTION[0].to_owned();
let mut right = FULL_COLLECTION[1].to_owned(); let mut right = FULL_COLLECTION[1].to_owned();
right.meta.id = left.meta.id.clone(); 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.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. // 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(); let mut expected = left.clone();
expected.meta.info.properties = expected expected.meta.info.properties = expected
@ -538,9 +547,12 @@ mod tests {
.info .info
.properties .properties
.merge(right.clone().meta.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.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); let merged = left.clone().merge(right);
assert_eq!(expected, merged); assert_eq!(expected, merged);