Add UT for date merge
Some checks failed
Cargo CI / Build and Test (pull_request) Successful in 2m1s
Cargo CI / Lint (pull_request) Failing after 1m7s

This commit is contained in:
Wojciech Kozlowski 2025-01-03 10:19:18 +01:00
parent 7296b6f31d
commit 19345d37eb

View File

@ -419,4 +419,39 @@ mod tests {
let merged = left.clone().merge(right);
assert_eq!(expected, merged);
}
#[test]
fn merge_album_dates() {
let meta = AlbumMeta::new(AlbumId::new("An album"));
// No merge if years are different.
let left = meta.clone().with_date((2000, 1, 6));
let right = meta.clone().with_date((1000, 2, 7));
let expected = meta.clone().with_date(left.date);
assert_eq!(expected, left.merge(right));
// No merge if years are the same but months/days are different.
let left = meta.clone().with_date((2000, 1, 6));
let right = meta.clone().with_date((2000, 2, 7));
let expected = meta.clone().with_date(left.date);
assert_eq!(expected, left.merge(right));
// No merge if right has no date.
let left = meta.clone().with_date((2000, 1, 6));
let right = meta.clone();
let expected = meta.clone().with_date(left.date);
assert_eq!(expected, left.merge(right));
// Merge if left has no date.
let left = meta.clone();
let right = meta.clone().with_date((2000, 2, 7));
let expected = meta.clone().with_date(right.date);
assert_eq!(expected, left.merge(right));
// Merge if left has no year but has months/days.
let left = meta.clone().with_date(AlbumDate::new(None, Some(1), Some(6)));
let right = meta.clone().with_date((2000, 2, 7));
let expected = meta.clone().with_date(right.date);
assert_eq!(expected, left.merge(right));
}
}