added a find function to model
This commit is contained in:
parent
125289ace1
commit
3e1e46ce2b
5 changed files with 16 additions and 11 deletions
|
@ -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}"),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue