From e31062d0ed8d026df2d0af99043aedf50d7c7455 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Thu, 12 Jun 2025 19:36:26 +0300 Subject: [PATCH] commands: add basic tests --- src/commands.rs | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/commands.rs b/src/commands.rs index 38dc0e55..eede5ad7 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -215,3 +215,33 @@ impl Commands { Ok(()) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[tokio::test] + async fn test_add_files_empty_list() { + let result = Commands::add_files(&[]).await; + assert!(result.is_err()); + if let Err(MrcError::InvalidInput(msg)) = result { + assert_eq!(msg, "No files provided to add to the playlist"); + } else { + panic!("Expected InvalidInput error"); + } + } + + #[tokio::test] + async fn test_replace_playlist_empty() { + let result = Commands::replace_playlist(&[]).await; + // Should succeed (no-op) with empty list + assert!(result.is_ok()); + } + + #[tokio::test] + async fn test_get_properties_empty() { + let result = Commands::get_properties(&[]).await; + // Should succeed (no-op) with empty list + assert!(result.is_ok()); + } +}