added a find function to model
This commit is contained in:
parent
125289ace1
commit
3e1e46ce2b
5 changed files with 16 additions and 11 deletions
|
@ -48,7 +48,7 @@ mod test {
|
|||
pub fn test_db_and_model() {
|
||||
let mut video_model: Model<Video> = Model::default();
|
||||
video_model.load_from_db();
|
||||
if let Some(video) = video_model.get_item(|v| v.id == 3) {
|
||||
if let Some(video) = video_model.find(|v| v.id == 73) {
|
||||
let test_video = test_video("Getting started with Tokio. The ultimate starter guide to writing async Rust.".into());
|
||||
assert_eq!(test_video.title, video.title);
|
||||
} else {
|
||||
|
@ -64,10 +64,10 @@ mod test {
|
|||
let new_video = test_video("A newer video".into());
|
||||
match result {
|
||||
Ok(_) => {
|
||||
assert_eq!(&video, video_model.get_item(|v| v.id == 0).unwrap());
|
||||
assert_eq!(&video, video_model.find(|v| v.id == 0).unwrap());
|
||||
assert_ne!(
|
||||
&new_video,
|
||||
video_model.get_item(|v| v.id == 0).unwrap()
|
||||
video_model.find(|v| v.id == 0).unwrap()
|
||||
);
|
||||
}
|
||||
Err(e) => assert!(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue