From 1ed04a1f64a6b312802289dd6a33e1cfcec254c8 Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Tue, 25 Mar 2025 10:09:15 -0500 Subject: [PATCH] fixing some test --- src/core/images.rs | 7 +++--- src/core/presentations.rs | 5 +++-- src/core/songs.rs | 11 +++++---- src/core/videos.rs | 7 +++--- src/lisp.rs | 47 +++++++++++++++++++++------------------ src/ui/presenter.rs | 2 +- 6 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/core/images.rs b/src/core/images.rs index c04bf3c..4eb16dd 100644 --- a/src/core/images.rs +++ b/src/core/images.rs @@ -217,9 +217,10 @@ mod test { pub async fn test_db_and_model() { let mut image_model: Model = Model { items: vec![], - db: crate::core::model::get_db().await, + kind: LibraryKind::Image, }; - image_model.load_from_db().await; + let mut db = crate::core::model::get_db().await; + image_model.load_from_db(&mut db).await; if let Some(image) = image_model.find(|i| i.id == 3) { let test_image = test_image("nccq5".into()); assert_eq!(test_image.title, image.title); @@ -233,7 +234,7 @@ mod test { let image = test_image("A new image".into()); let mut image_model: Model = Model { items: vec![], - db: crate::core::model::get_db().await, + kind: LibraryKind::Image, }; let result = image_model.add_item(image.clone()); let new_image = test_image("A newer image".into()); diff --git a/src/core/presentations.rs b/src/core/presentations.rs index 3ee3ecb..164a9dd 100644 --- a/src/core/presentations.rs +++ b/src/core/presentations.rs @@ -275,9 +275,10 @@ mod test { async fn test_db_and_model() { let mut presentation_model: Model = Model { items: vec![], - db: crate::core::model::get_db().await, + kind: LibraryKind::Presentation, }; - presentation_model.load_from_db().await; + let mut db = crate::core::model::get_db().await; + presentation_model.load_from_db(&mut db).await; if let Some(presentation) = presentation_model.find(|p| p.id == 54) { diff --git a/src/core/songs.rs b/src/core/songs.rs index b6984c8..52f4b13 100644 --- a/src/core/songs.rs +++ b/src/core/songs.rs @@ -641,15 +641,17 @@ You saved my soul" async fn model() -> Model { let song_model: Model = Model { items: vec![], - db: crate::core::model::get_db().await, + kind: LibraryKind::Song, + // db: crate::core::model::get_db().await, }; song_model } #[tokio::test] async fn test_db_and_model() { + let mut db = crate::core::model::get_db().await; let mut song_model = model().await; - song_model.load_from_db().await; + song_model.load_from_db(&mut db).await; if let Some(song) = song_model.find(|s| s.id == 7) { let test_song = test_song(); assert_eq!(&test_song, song); @@ -662,7 +664,7 @@ You saved my soul" #[tokio::test] async fn test_song_from_db() { let song = test_song(); - let mut db = model().await.db; + let mut db = crate::core::model::get_db().await; let result = get_song_from_db(7, &mut db).await; match result { Ok(db_song) => assert_eq!(song, db_song), @@ -672,10 +674,11 @@ You saved my soul" #[tokio::test] async fn test_update() { + let mut db = crate::core::model::get_db().await; let song = test_song(); let cloned_song = song.clone(); let mut song_model: Model = model().await; - song_model.load_from_db().await; + song_model.load_from_db(&mut db).await; match song_model.update_item(song, 2) { Ok(()) => assert_eq!( diff --git a/src/core/videos.rs b/src/core/videos.rs index 34f8b03..c3fe4e0 100644 --- a/src/core/videos.rs +++ b/src/core/videos.rs @@ -259,9 +259,10 @@ mod test { async fn test_db_and_model() { let mut video_model: Model