From 5f2d1897b245fbee12d17b5910eaf5233ca6802b Mon Sep 17 00:00:00 2001 From: salmonik Date: Tue, 5 May 2026 23:29:39 +0200 Subject: Add unit tests in /tests directory for config, database, playback, and scrobbler modules --- src/audio.rs | 1 + src/database.rs | 4 ++-- src/lib.rs | 7 +++++++ src/playback.rs | 13 +++++++------ src/scrobbler.rs | 8 ++++---- 5 files changed, 21 insertions(+), 12 deletions(-) create mode 100644 src/lib.rs (limited to 'src') diff --git a/src/audio.rs b/src/audio.rs index 93eb8e6..d716a23 100644 --- a/src/audio.rs +++ b/src/audio.rs @@ -21,6 +21,7 @@ pub struct AudioEngine { volume: Arc>, } +#[allow(clippy::new_without_default)] impl AudioEngine { pub fn new() -> Self { let (tx, rx) = mpsc::channel(); diff --git a/src/database.rs b/src/database.rs index 9d1d5f2..b7b8e88 100644 --- a/src/database.rs +++ b/src/database.rs @@ -220,7 +220,7 @@ impl Database { } } -fn is_audio_file(path: &Path) -> bool { +pub fn is_audio_file(path: &Path) -> bool { path.extension() .and_then(|ext| ext.to_str()) .map(|ext| { @@ -232,7 +232,7 @@ fn is_audio_file(path: &Path) -> bool { .unwrap_or(false) } -fn extract_metadata(path: &Path) -> (String, String, String, Option, Option) { +pub fn extract_metadata(path: &Path) -> (String, String, String, Option, Option) { let file_stem = path .file_stem() .and_then(|s| s.to_str()) diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..9317bcd --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,7 @@ +pub mod audio; +pub mod cli; +pub mod config; +pub mod daemon; +pub mod database; +pub mod playback; +pub mod scrobbler; diff --git a/src/playback.rs b/src/playback.rs index 76c0f44..d9dd1f9 100644 --- a/src/playback.rs +++ b/src/playback.rs @@ -18,7 +18,7 @@ pub struct Track { pub duration: Option, } -#[derive(Debug, Clone)] +#[derive(Debug, Clone, PartialEq)] #[allow(dead_code)] pub enum ShuffleMode { None, @@ -28,14 +28,15 @@ pub enum ShuffleMode { #[allow(dead_code)] pub struct Player { - state: PlaybackState, - current_track: Option, - queue: Vec, - volume: u8, - shuffle: ShuffleMode, + pub state: PlaybackState, + pub current_track: Option, + pub queue: Vec, + pub volume: u8, + pub shuffle: ShuffleMode, } #[allow(dead_code)] +#[allow(clippy::new_without_default)] impl Player { pub fn new() -> Self { Player { diff --git a/src/scrobbler.rs b/src/scrobbler.rs index 09a7f55..ddcbed9 100644 --- a/src/scrobbler.rs +++ b/src/scrobbler.rs @@ -2,10 +2,10 @@ use reqwest::Client; #[allow(dead_code)] pub struct Scrobbler { - lastfm_api_key: Option, - lastfm_api_secret: Option, - lastfm_session_key: Option, - listenbrainz_token: Option, + pub lastfm_api_key: Option, + pub lastfm_api_secret: Option, + pub lastfm_session_key: Option, + pub listenbrainz_token: Option, client: Client, } -- cgit v1.2.3