Update pre_commit on reloads
This commit is contained in:
parent
8bfde534e5
commit
91945e7fcb
@ -220,6 +220,8 @@ impl<LIB, DB: IDatabase> MusicHoard<LIB, DB> {
|
|||||||
Self::sort_albums_and_tracks(self.collection.iter_mut());
|
Self::sort_albums_and_tracks(self.collection.iter_mut());
|
||||||
|
|
||||||
self.merge_collections();
|
self.merge_collections();
|
||||||
|
self.pre_commit = self.collection.clone();
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -398,7 +400,9 @@ mod tests {
|
|||||||
let artist_id = ArtistId::new("an artist");
|
let artist_id = ArtistId::new("an artist");
|
||||||
let artist_id_2 = ArtistId::new("another artist");
|
let artist_id_2 = ArtistId::new("another artist");
|
||||||
|
|
||||||
let with_artist = vec![Artist::new(artist_id.clone())];
|
let collection = FULL_COLLECTION.to_owned();
|
||||||
|
let mut with_artist = collection.clone();
|
||||||
|
with_artist.push(Artist::new(artist_id.clone()));
|
||||||
|
|
||||||
let mut database = MockIDatabase::new();
|
let mut database = MockIDatabase::new();
|
||||||
let mut seq = Sequence::new();
|
let mut seq = Sequence::new();
|
||||||
@ -407,7 +411,7 @@ mod tests {
|
|||||||
.times(1)
|
.times(1)
|
||||||
.times(1)
|
.times(1)
|
||||||
.in_sequence(&mut seq)
|
.in_sequence(&mut seq)
|
||||||
.returning(|| Ok(vec![]));
|
.returning(|| Ok(FULL_COLLECTION.to_owned()));
|
||||||
database
|
database
|
||||||
.expect_save()
|
.expect_save()
|
||||||
.times(1)
|
.times(1)
|
||||||
@ -418,10 +422,11 @@ mod tests {
|
|||||||
.expect_save()
|
.expect_save()
|
||||||
.times(1)
|
.times(1)
|
||||||
.in_sequence(&mut seq)
|
.in_sequence(&mut seq)
|
||||||
.with(predicate::eq(vec![]))
|
.with(predicate::eq(collection.clone()))
|
||||||
.returning(|_| Ok(()));
|
.returning(|_| Ok(()));
|
||||||
|
|
||||||
let mut music_hoard = MusicHoard::database(database).unwrap();
|
let mut music_hoard = MusicHoard::database(database).unwrap();
|
||||||
|
assert_eq!(music_hoard.collection, collection);
|
||||||
|
|
||||||
assert!(music_hoard.add_artist(artist_id.clone()).is_ok());
|
assert!(music_hoard.add_artist(artist_id.clone()).is_ok());
|
||||||
assert_eq!(music_hoard.collection, with_artist);
|
assert_eq!(music_hoard.collection, with_artist);
|
||||||
@ -433,7 +438,7 @@ mod tests {
|
|||||||
assert_eq!(music_hoard.collection, with_artist);
|
assert_eq!(music_hoard.collection, with_artist);
|
||||||
|
|
||||||
assert!(music_hoard.remove_artist(&artist_id).is_ok());
|
assert!(music_hoard.remove_artist(&artist_id).is_ok());
|
||||||
assert_eq!(music_hoard.collection, vec![]);
|
assert_eq!(music_hoard.collection, collection);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user