Add UT for date merge
This commit is contained in:
parent
7296b6f31d
commit
19345d37eb
@ -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));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user