diff options
| author | salmonik <raisersoft@proton.me> | 2026-05-05 23:29:39 +0200 |
|---|---|---|
| committer | salmonik <raisersoft@proton.me> | 2026-05-05 23:29:39 +0200 |
| commit | 5f2d1897b245fbee12d17b5910eaf5233ca6802b (patch) | |
| tree | 551b8855ade2f31e0f24539504b0f9b66cdba75f /src | |
| parent | Add dev/release config separation and volume query command (diff) | |
| download | rsplayer-5f2d1897b245fbee12d17b5910eaf5233ca6802b.tar.gz rsplayer-5f2d1897b245fbee12d17b5910eaf5233ca6802b.zip | |
Add unit tests in /tests directory for config, database, playback, and scrobbler modules
Diffstat (limited to '')
| -rw-r--r-- | src/audio.rs | 1 | ||||
| -rw-r--r-- | src/database.rs | 4 | ||||
| -rw-r--r-- | src/lib.rs | 7 | ||||
| -rw-r--r-- | src/playback.rs | 13 | ||||
| -rw-r--r-- | src/scrobbler.rs | 8 |
5 files changed, 21 insertions, 12 deletions
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 { | |||
| 21 | volume: Arc<Mutex<f32>>, | 21 | volume: Arc<Mutex<f32>>, |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | #[allow(clippy::new_without_default)] | ||
| 24 | impl AudioEngine { | 25 | impl AudioEngine { |
| 25 | pub fn new() -> Self { | 26 | pub fn new() -> Self { |
| 26 | let (tx, rx) = mpsc::channel(); | 27 | 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 { | |||
| 220 | } | 220 | } |
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | fn is_audio_file(path: &Path) -> bool { | 223 | pub fn is_audio_file(path: &Path) -> bool { |
| 224 | path.extension() | 224 | path.extension() |
| 225 | .and_then(|ext| ext.to_str()) | 225 | .and_then(|ext| ext.to_str()) |
| 226 | .map(|ext| { | 226 | .map(|ext| { |
| @@ -232,7 +232,7 @@ fn is_audio_file(path: &Path) -> bool { | |||
| 232 | .unwrap_or(false) | 232 | .unwrap_or(false) |
| 233 | } | 233 | } |
| 234 | 234 | ||
| 235 | fn extract_metadata(path: &Path) -> (String, String, String, Option<i32>, Option<u64>) { | 235 | pub fn extract_metadata(path: &Path) -> (String, String, String, Option<i32>, Option<u64>) { |
| 236 | let file_stem = path | 236 | let file_stem = path |
| 237 | .file_stem() | 237 | .file_stem() |
| 238 | .and_then(|s| s.to_str()) | 238 | .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 @@ | |||
| 1 | pub mod audio; | ||
| 2 | pub mod cli; | ||
| 3 | pub mod config; | ||
| 4 | pub mod daemon; | ||
| 5 | pub mod database; | ||
| 6 | pub mod playback; | ||
| 7 | 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 { | |||
| 18 | pub duration: Option<u64>, | 18 | pub duration: Option<u64>, |
| 19 | } | 19 | } |
| 20 | 20 | ||
| 21 | #[derive(Debug, Clone)] | 21 | #[derive(Debug, Clone, PartialEq)] |
| 22 | #[allow(dead_code)] | 22 | #[allow(dead_code)] |
| 23 | pub enum ShuffleMode { | 23 | pub enum ShuffleMode { |
| 24 | None, | 24 | None, |
| @@ -28,14 +28,15 @@ pub enum ShuffleMode { | |||
| 28 | 28 | ||
| 29 | #[allow(dead_code)] | 29 | #[allow(dead_code)] |
| 30 | pub struct Player { | 30 | pub struct Player { |
| 31 | state: PlaybackState, | 31 | pub state: PlaybackState, |
| 32 | current_track: Option<Track>, | 32 | pub current_track: Option<Track>, |
| 33 | queue: Vec<Track>, | 33 | pub queue: Vec<Track>, |
| 34 | volume: u8, | 34 | pub volume: u8, |
| 35 | shuffle: ShuffleMode, | 35 | pub shuffle: ShuffleMode, |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | #[allow(dead_code)] | 38 | #[allow(dead_code)] |
| 39 | #[allow(clippy::new_without_default)] | ||
| 39 | impl Player { | 40 | impl Player { |
| 40 | pub fn new() -> Self { | 41 | pub fn new() -> Self { |
| 41 | Player { | 42 | 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; | |||
| 2 | 2 | ||
| 3 | #[allow(dead_code)] | 3 | #[allow(dead_code)] |
| 4 | pub struct Scrobbler { | 4 | pub struct Scrobbler { |
| 5 | lastfm_api_key: Option<String>, | 5 | pub lastfm_api_key: Option<String>, |
| 6 | lastfm_api_secret: Option<String>, | 6 | pub lastfm_api_secret: Option<String>, |
| 7 | lastfm_session_key: Option<String>, | 7 | pub lastfm_session_key: Option<String>, |
| 8 | listenbrainz_token: Option<String>, | 8 | pub listenbrainz_token: Option<String>, |
| 9 | client: Client, | 9 | client: Client, |
| 10 | } | 10 | } |
| 11 | 11 | ||
