From ccc9dca924b4f7fc00f250eece01e97efb54690b Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sun, 21 Jun 2026 09:33:50 +0200 Subject: [PATCH] fix: resolve all Rust test compile warnings without suppression Remove unused imports and a dead test helper, and strengthen tests that held unused bindings/fields so the values are actually exercised: - drop unused imports (HttpConfig, MediaType, std::io::Write) - remove unused TestEventEmitter::clear helper - replace meaningless size_of asserts with real empty-manager checks - assert on MockTrack.name in sorting tests --- src-tauri/src/commands/player/mod.rs | 2 ++ src-tauri/src/commands/repository.rs | 8 ++++---- src-tauri/src/connectivity/mod.rs | 1 - src-tauri/src/download/mod.rs | 1 - src-tauri/src/player/events.rs | 4 ---- src-tauri/src/thumbnail/cache.rs | 1 - 6 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src-tauri/src/commands/player/mod.rs b/src-tauri/src/commands/player/mod.rs index e931f6f..300cbb4 100644 --- a/src-tauri/src/commands/player/mod.rs +++ b/src-tauri/src/commands/player/mod.rs @@ -1796,6 +1796,7 @@ mod tests { // Test finding track 1 (should be index 0) let index1 = tracks.iter().position(|t| t.id == "track1"); assert_eq!(index1, Some(0), "Track 1 should be at index 0"); + assert_eq!(tracks[0].name, "Song 1", "Track at index 0 should carry its name"); // Test finding track 3 (should be index 2) let index3 = tracks.iter().position(|t| t.id == "track3"); @@ -1869,6 +1870,7 @@ mod tests { // Verify all tracks are in correct order assert_eq!(tracks[0].id, "id1"); + assert_eq!(tracks[0].name, "Track 1", "Sorted track should retain its name"); assert_eq!(tracks[1].id, "id2"); assert_eq!(tracks[2].id, "id3"); assert_eq!(tracks[3].id, "id4"); diff --git a/src-tauri/src/commands/repository.rs b/src-tauri/src/commands/repository.rs index b82ddc1..a5b00eb 100644 --- a/src-tauri/src/commands/repository.rs +++ b/src-tauri/src/commands/repository.rs @@ -499,16 +499,16 @@ mod tests { #[test] fn test_repository_manager_creation() { let manager = RepositoryManager::new(); - // Should be able to create RepositoryManager without panicking - assert_eq!(std::mem::size_of::() > 0, true); + // A freshly created manager holds no repositories + assert!(manager.get("any-handle").is_none()); } #[test] fn test_repository_manager_wrapper_structure() { let manager = RepositoryManager::new(); let wrapper = RepositoryManagerWrapper(manager); - // Verify wrapper holds the manager - assert_eq!(std::mem::size_of::() > 0, true); + // The wrapper exposes the underlying manager, which starts empty + assert!(wrapper.0.get("any-handle").is_none()); } #[test] diff --git a/src-tauri/src/connectivity/mod.rs b/src-tauri/src/connectivity/mod.rs index 26263f0..be6e941 100644 --- a/src-tauri/src/connectivity/mod.rs +++ b/src-tauri/src/connectivity/mod.rs @@ -349,7 +349,6 @@ impl ConnectivityMonitorHandle { #[cfg(test)] mod tests { use super::*; - use crate::jellyfin::http_client::HttpConfig; #[test] fn test_intervals() { diff --git a/src-tauri/src/download/mod.rs b/src-tauri/src/download/mod.rs index bfb598d..2406da4 100644 --- a/src-tauri/src/download/mod.rs +++ b/src-tauri/src/download/mod.rs @@ -120,7 +120,6 @@ pub struct DownloadTask { #[cfg(test)] mod tests { use super::*; - use crate::player::MediaType; #[test] fn test_download_manager_set_max_concurrent() { diff --git a/src-tauri/src/player/events.rs b/src-tauri/src/player/events.rs index 60d9373..9ee8c80 100644 --- a/src-tauri/src/player/events.rs +++ b/src-tauri/src/player/events.rs @@ -172,10 +172,6 @@ mod tests { pub fn events(&self) -> Vec { self.events.lock_safe().clone() } - - pub fn clear(&self) { - self.events.lock_safe().clear(); - } } impl PlayerEventEmitter for TestEventEmitter { diff --git a/src-tauri/src/thumbnail/cache.rs b/src-tauri/src/thumbnail/cache.rs index b6b9630..4980af7 100644 --- a/src-tauri/src/thumbnail/cache.rs +++ b/src-tauri/src/thumbnail/cache.rs @@ -344,7 +344,6 @@ mod tests { use super::*; use crate::storage::db_service::RusqliteService; use rusqlite::Connection; - use std::io::Write; use std::sync::{Arc, Mutex}; use tempfile::TempDir;