From 7bdd8225cba276fc06cee734fb71692c90e3f31e Mon Sep 17 00:00:00 2001 From: Chris Cochrun Date: Sun, 1 Oct 2023 06:39:52 -0500 Subject: [PATCH] fixing some unused imports --- src/rust/image_model.rs | 2 +- src/rust/presentation_model.rs | 7 +++---- src/rust/reveal_js.rs | 18 +++++++++++++++--- src/rust/songs/song_model.rs | 29 +++++++++++++++++++++++++++++ 4 files changed, 48 insertions(+), 8 deletions(-) diff --git a/src/rust/image_model.rs b/src/rust/image_model.rs index 5eeaffc..d3fa560 100644 --- a/src/rust/image_model.rs +++ b/src/rust/image_model.rs @@ -4,7 +4,7 @@ mod image_model { use crate::schema::images::dsl::*; use diesel::sqlite::SqliteConnection; use diesel::{delete, insert_into, prelude::*, update}; - use std::path::{Path, PathBuf}; + use std::path::PathBuf; unsafe extern "C++" { include!(< QAbstractListModel >); diff --git a/src/rust/presentation_model.rs b/src/rust/presentation_model.rs index a5d4907..4560713 100644 --- a/src/rust/presentation_model.rs +++ b/src/rust/presentation_model.rs @@ -1,14 +1,13 @@ #[cxx_qt::bridge] mod presentation_model { - use crate::models::*; use crate::presentation_model::presentation_model::Presentation; use crate::reveal_js; use crate::schema::presentations::dsl::*; use diesel::sqlite::SqliteConnection; use diesel::{delete, insert_into, prelude::*, update}; // use sqlx::Connection; - use std::path::{Path, PathBuf}; - use tracing::{debug, debug_span, error, info, instrument}; + use std::path::PathBuf; + use tracing::debug; unsafe extern "C++" { include!(< QAbstractListModel >); @@ -228,7 +227,7 @@ mod presentation_model { ); actual_page_count = reveal_js::count_slides_and_fragments( - actual_path, + &actual_path, ); } debug!( diff --git a/src/rust/reveal_js.rs b/src/rust/reveal_js.rs index 027e5f8..47cbcce 100644 --- a/src/rust/reveal_js.rs +++ b/src/rust/reveal_js.rs @@ -1,8 +1,8 @@ // use dirs; -use std::{fs::read_to_string, path::PathBuf}; -use tracing::{debug, debug_span, error, info, instrument}; +use std::{fs::read_to_string, path::Path}; +use tracing::debug; -pub fn count_slides_and_fragments(html_file_path: PathBuf) -> i32 { +pub fn count_slides_and_fragments(html_file_path: &Path) -> i32 { debug!(path = ?html_file_path, "Starting slide counter"); // Read the HTML file let html_content = read_to_string(html_file_path) @@ -31,3 +31,15 @@ pub fn count_slides_and_fragments(html_file_path: PathBuf) -> i32 { total as i32 } + +#[cfg(test)] +mod tests { + use super::*; + use std::path::Path; + + #[test] + fn count_slides_test() { + let html_file = Path::new("/home/chris/org/lessons/2023_24_1_adam_and_eve_lesson.html"); + assert_eq!(count_slides_and_fragments(html_file), 33); + } +} diff --git a/src/rust/songs/song_model.rs b/src/rust/songs/song_model.rs index 10b14d5..758eb67 100644 --- a/src/rust/songs/song_model.rs +++ b/src/rust/songs/song_model.rs @@ -1055,3 +1055,32 @@ pub mod song_model { } } } + +#[cfg(test)] +mod tests { + use super::*; + use cxx_qt_lib::QStringList; // Replace 'some_module' with the actual module where QModelIndex is defined. + + #[test] + fn test_get_lyric_list() { + // Create a test instance of your struct (you might need to adjust this based on your actual struct). + let mut song_model = SongModel { + highest_id: 0, + songs: Vec::::new(), + }; + + // this sets up the songmodel with the database + // song_model.setup_wrapper(self); + + // Call the get_lyric_list function with specific inputs. + let index = 0; // Replace with your desired test index. + + let result = song_model.get_lyric_list(index); + + // Define your expected result here. For simplicity, let's assume an empty QStringList. + let expected_result = QStringList::default(); + + // Compare the actual result with the expected result using an assertion. + assert_eq!(result, expected_result); + } +}