Artists with a _sort field show up twice #109
@ -19,7 +19,9 @@ cargo install grcov
|
||||
|
||||
```sh
|
||||
env CARGO_TARGET_DIR=codecov \
|
||||
cargo clean
|
||||
rm -rf ./codecov/debug/{coverage,profraw}
|
||||
env CARGO_TARGET_DIR=codecov \
|
||||
cargo clean -p musichoard
|
||||
env RUSTFLAGS="-C instrument-coverage" \
|
||||
LLVM_PROFILE_FILE="codecov/debug/profraw/musichoard-%p-%m.profraw" \
|
||||
CARGO_TARGET_DIR=codecov \
|
||||
|
41
src/lib.rs
41
src/lib.rs
@ -1905,7 +1905,11 @@ mod tests {
|
||||
expected.tracks.append(&mut right.tracks.clone());
|
||||
expected.tracks.sort_unstable();
|
||||
|
||||
let merged = left.clone().merge(right);
|
||||
let merged = left.clone().merge(right.clone());
|
||||
assert_eq!(expected, merged);
|
||||
|
||||
// Non-overlapping merge should be commutative.
|
||||
let merged = right.clone().merge(left.clone());
|
||||
assert_eq!(expected, merged);
|
||||
}
|
||||
|
||||
@ -1931,13 +1935,18 @@ mod tests {
|
||||
let left = COLLECTION[0].to_owned();
|
||||
let mut right = COLLECTION[1].to_owned();
|
||||
right.id = left.id.clone();
|
||||
right.properties = ArtistProperties::default();
|
||||
|
||||
let mut expected = left.clone();
|
||||
expected.properties = expected.properties.merge(right.clone().properties);
|
||||
expected.albums.append(&mut right.albums.clone());
|
||||
expected.albums.sort_unstable();
|
||||
|
||||
let merged = left.clone().merge(right);
|
||||
let merged = left.clone().merge(right.clone());
|
||||
assert_eq!(expected, merged);
|
||||
|
||||
// Non-overlapping merge should be commutative.
|
||||
let merged = right.clone().merge(left.clone());
|
||||
assert_eq!(expected, merged);
|
||||
}
|
||||
|
||||
@ -1969,8 +1978,13 @@ mod tests {
|
||||
let mut expected = COLLECTION.to_owned();
|
||||
expected.sort_unstable();
|
||||
|
||||
let mut merged = left;
|
||||
MusicHoard::<NoLibrary, NoDatabase>::merge_in_place(&mut merged, right);
|
||||
let mut merged = left.clone();
|
||||
MusicHoard::<NoLibrary, NoDatabase>::merge_in_place(&mut merged, right.clone());
|
||||
assert_eq!(expected, merged);
|
||||
|
||||
// The merge is completele non-overlapping so it should be commutative.
|
||||
let mut merged = right.clone();
|
||||
MusicHoard::<NoLibrary, NoDatabase>::merge_in_place(&mut merged, left.clone());
|
||||
assert_eq!(expected, merged);
|
||||
}
|
||||
|
||||
@ -1984,8 +1998,13 @@ mod tests {
|
||||
let mut expected = COLLECTION.to_owned();
|
||||
expected.sort_unstable();
|
||||
|
||||
let mut merged = left;
|
||||
MusicHoard::<NoLibrary, NoDatabase>::merge_in_place(&mut merged, right);
|
||||
let mut merged = left.clone();
|
||||
MusicHoard::<NoLibrary, NoDatabase>::merge_in_place(&mut merged, right.clone());
|
||||
assert_eq!(expected, merged);
|
||||
|
||||
// The merge does not overwrite any data so it should be commutative.
|
||||
let mut merged = right.clone();
|
||||
MusicHoard::<NoLibrary, NoDatabase>::merge_in_place(&mut merged, left.clone());
|
||||
assert_eq!(expected, merged);
|
||||
}
|
||||
|
||||
@ -2012,8 +2031,14 @@ mod tests {
|
||||
expected.last_mut().map(|a| a.sort = artist_sort.clone());
|
||||
expected.rotate_right(1);
|
||||
|
||||
let mut merged = left;
|
||||
MusicHoard::<NoLibrary, NoDatabase>::merge_in_place(&mut merged, right);
|
||||
let mut merged = left.clone();
|
||||
MusicHoard::<NoLibrary, NoDatabase>::merge_in_place(&mut merged, right.clone());
|
||||
assert_eq!(expected.len(), merged.len());
|
||||
assert_eq!(expected, merged);
|
||||
|
||||
// The merge overwrites the sort data, but no data is erased so it should be commutative.
|
||||
let mut merged = right.clone();
|
||||
MusicHoard::<NoLibrary, NoDatabase>::merge_in_place(&mut merged, left.clone());
|
||||
assert_eq!(expected.len(), merged.len());
|
||||
assert_eq!(expected, merged);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user