diff --git a/src/cli/sonarr/get_command_handler.rs b/src/cli/sonarr/get_command_handler.rs index c0356ce..8d29cbc 100644 --- a/src/cli/sonarr/get_command_handler.rs +++ b/src/cli/sonarr/get_command_handler.rs @@ -19,6 +19,8 @@ mod get_command_handler_tests; #[derive(Debug, Clone, PartialEq, Eq, Subcommand)] pub enum SonarrGetCommand { + #[command(about = "Get the shared settings for all indexers")] + AllIndexerSettings, #[command(about = "Get detailed information for the episode with the given ID")] EpisodeDetails { #[arg( @@ -63,6 +65,9 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, SonarrGetCommand> for SonarrGetCommandHan async fn handle(self) -> Result<()> { match self.command { + SonarrGetCommand::AllIndexerSettings => { + execute_network_event!(self, SonarrEvent::GetAllIndexerSettings); + } SonarrGetCommand::EpisodeDetails { episode_id } => { execute_network_event!(self, SonarrEvent::GetEpisodeDetails(Some(episode_id))); } diff --git a/src/cli/sonarr/get_command_handler_tests.rs b/src/cli/sonarr/get_command_handler_tests.rs index 00e7a38..8905048 100644 --- a/src/cli/sonarr/get_command_handler_tests.rs +++ b/src/cli/sonarr/get_command_handler_tests.rs @@ -21,6 +21,14 @@ mod tests { use super::*; + #[test] + fn test_all_indexer_settings_has_no_arg_requirements() { + let result = + Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "all-indexer-settings"]); + + assert!(result.is_ok()); + } + #[test] fn test_system_status_has_no_arg_requirements() { let result = @@ -89,6 +97,34 @@ mod tests { network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent}, }; + #[tokio::test] + async fn test_handle_get_all_indexer_settings_command() { + let mut mock_network = MockNetworkTrait::new(); + mock_network + .expect_handle_network_event() + .with(eq::( + SonarrEvent::GetAllIndexerSettings.into(), + )) + .times(1) + .returning(|_| { + Ok(Serdeable::Sonarr(SonarrSerdeable::Value( + json!({"testResponse": "response"}), + ))) + }); + let app_arc = Arc::new(Mutex::new(App::default())); + let get_all_indexer_settings_command = SonarrGetCommand::AllIndexerSettings; + + let result = SonarrGetCommandHandler::with( + &app_arc, + get_all_indexer_settings_command, + &mut mock_network, + ) + .handle() + .await; + + assert!(result.is_ok()); + } + #[tokio::test] async fn test_handle_get_episode_details_command() { let expected_episode_id = 1; diff --git a/src/models/sonarr_models.rs b/src/models/sonarr_models.rs index cdec965..7e3505d 100644 --- a/src/models/sonarr_models.rs +++ b/src/models/sonarr_models.rs @@ -112,7 +112,7 @@ pub struct IndexerSettings { #[serde(deserialize_with = "super::from_i64")] pub id: i64, #[serde(deserialize_with = "super::from_i64")] - pub mimimum_age: i64, + pub minimum_age: i64, #[serde(deserialize_with = "super::from_i64")] pub retention: i64, #[serde(deserialize_with = "super::from_i64")]