added a find function to model

This commit is contained in:
Chris Cochrun 2024-10-09 15:47:53 -05:00
parent 125289ace1
commit 3e1e46ce2b
5 changed files with 16 additions and 11 deletions

View file

@ -282,7 +282,7 @@ You saved my soul"
pub fn test_db_and_model() {
let mut song_model: Model<Song> = Model::default();
song_model.load_from_db();
if let Some(song) = song_model.get_item(|s| s.id == 7) {
if let Some(song) = song_model.find(|s| s.id == 7) {
let test_song = test_song();
assert_eq!(&test_song, song);
} else {
@ -310,7 +310,7 @@ You saved my soul"
match song_model.update_item(song, 2) {
Ok(()) => assert_eq!(
&cloned_song,
song_model.get_item(|s| s.id == 7).unwrap()
song_model.find(|s| s.id == 7).unwrap()
),
Err(e) => assert!(false, "{e}"),
}