feat(cli): Added Sonarr support for fetching host and security configs
This commit is contained in:
@@ -28,6 +28,10 @@ pub enum SonarrGetCommand {
|
||||
)]
|
||||
episode_id: i64,
|
||||
},
|
||||
#[command(about = "Fetch the host config for your Sonarr instance")]
|
||||
HostConfig,
|
||||
#[command(about = "Fetch the security config for your Sonarr instance")]
|
||||
SecurityConfig,
|
||||
#[command(about = "Get the system status")]
|
||||
SystemStatus,
|
||||
}
|
||||
@@ -62,6 +66,12 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, SonarrGetCommand> for SonarrGetCommandHan
|
||||
SonarrGetCommand::EpisodeDetails { episode_id } => {
|
||||
execute_network_event!(self, SonarrEvent::GetEpisodeDetails(Some(episode_id)));
|
||||
}
|
||||
SonarrGetCommand::HostConfig => {
|
||||
execute_network_event!(self, SonarrEvent::GetHostConfig);
|
||||
}
|
||||
SonarrGetCommand::SecurityConfig => {
|
||||
execute_network_event!(self, SonarrEvent::GetSecurityConfig);
|
||||
}
|
||||
SonarrGetCommand::SystemStatus => {
|
||||
execute_network_event!(self, SonarrEvent::GetStatus);
|
||||
}
|
||||
|
||||
@@ -54,6 +54,22 @@ mod tests {
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_host_config_has_no_arg_requirements() {
|
||||
let result =
|
||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "host-config"]);
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_security_config_has_no_arg_requirements() {
|
||||
let result =
|
||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "get", "security-config"]);
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
}
|
||||
|
||||
mod handler {
|
||||
@@ -99,6 +115,52 @@ mod tests {
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_handle_get_host_config_command() {
|
||||
let mut mock_network = MockNetworkTrait::new();
|
||||
mock_network
|
||||
.expect_handle_network_event()
|
||||
.with(eq::<NetworkEvent>(SonarrEvent::GetHostConfig.into()))
|
||||
.times(1)
|
||||
.returning(|_| {
|
||||
Ok(Serdeable::Sonarr(SonarrSerdeable::Value(
|
||||
json!({"testResponse": "response"}),
|
||||
)))
|
||||
});
|
||||
let app_arc = Arc::new(Mutex::new(App::default()));
|
||||
let get_host_config_command = SonarrGetCommand::HostConfig;
|
||||
|
||||
let result =
|
||||
SonarrGetCommandHandler::with(&app_arc, get_host_config_command, &mut mock_network)
|
||||
.handle()
|
||||
.await;
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_handle_get_security_config_command() {
|
||||
let mut mock_network = MockNetworkTrait::new();
|
||||
mock_network
|
||||
.expect_handle_network_event()
|
||||
.with(eq::<NetworkEvent>(SonarrEvent::GetSecurityConfig.into()))
|
||||
.times(1)
|
||||
.returning(|_| {
|
||||
Ok(Serdeable::Sonarr(SonarrSerdeable::Value(
|
||||
json!({"testResponse": "response"}),
|
||||
)))
|
||||
});
|
||||
let app_arc = Arc::new(Mutex::new(App::default()));
|
||||
let get_security_config_command = SonarrGetCommand::SecurityConfig;
|
||||
|
||||
let result =
|
||||
SonarrGetCommandHandler::with(&app_arc, get_security_config_command, &mut mock_network)
|
||||
.handle()
|
||||
.await;
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_handle_get_system_status_command() {
|
||||
let mut mock_network = MockNetworkTrait::new();
|
||||
|
||||
Reference in New Issue
Block a user