fixing some test
This commit is contained in:
parent
4500fe7bf1
commit
1ed04a1f64
6 changed files with 44 additions and 35 deletions
|
@ -217,9 +217,10 @@ mod test {
|
|||
pub async fn test_db_and_model() {
|
||||
let mut image_model: Model<Image> = 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<Image> = 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());
|
||||
|
|
|
@ -275,9 +275,10 @@ mod test {
|
|||
async fn test_db_and_model() {
|
||||
let mut presentation_model: Model<Presentation> = 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)
|
||||
{
|
||||
|
|
|
@ -641,15 +641,17 @@ You saved my soul"
|
|||
async fn model() -> Model<Song> {
|
||||
let song_model: Model<Song> = 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<Song> = 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!(
|
||||
|
|
|
@ -259,9 +259,10 @@ mod test {
|
|||
async fn test_db_and_model() {
|
||||
let mut video_model: Model<Video> = Model {
|
||||
items: vec![],
|
||||
db: crate::core::model::get_db().await,
|
||||
kind: LibraryKind::Video,
|
||||
};
|
||||
video_model.load_from_db().await;
|
||||
let mut db = crate::core::model::get_db().await;
|
||||
video_model.load_from_db(&mut db).await;
|
||||
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."
|
||||
|
@ -278,7 +279,7 @@ mod test {
|
|||
let video = test_video("A new video".into());
|
||||
let mut video_model: Model<Video> = Model {
|
||||
items: vec![],
|
||||
db: crate::core::model::get_db().await,
|
||||
kind: LibraryKind::Video,
|
||||
};
|
||||
let result = video_model.add_item(video.clone());
|
||||
let new_video = test_video("A newer video".into());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue