Added the ability to fetch host configs and security configs to the CLI
This commit is contained in:
@@ -21,6 +21,8 @@ mod get_command_handler_tests;
|
||||
pub enum RadarrGetCommand {
|
||||
#[command(about = "Get the shared settings for all indexers")]
|
||||
AllIndexerSettings,
|
||||
#[command(about = "Fetch the host config for your Radarr instance")]
|
||||
HostConfig,
|
||||
#[command(about = "Get detailed information for the movie with the given ID")]
|
||||
MovieDetails {
|
||||
#[arg(
|
||||
@@ -39,6 +41,8 @@ pub enum RadarrGetCommand {
|
||||
)]
|
||||
movie_id: i64,
|
||||
},
|
||||
#[command(about = "Fetch the security config for your Radarr instance")]
|
||||
SecurityConfig,
|
||||
#[command(about = "Get the system status")]
|
||||
SystemStatus,
|
||||
}
|
||||
@@ -73,12 +77,18 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, RadarrGetCommand> for RadarrGetCommandHan
|
||||
RadarrGetCommand::AllIndexerSettings => {
|
||||
execute_network_event!(self, RadarrEvent::GetAllIndexerSettings);
|
||||
}
|
||||
RadarrGetCommand::HostConfig => {
|
||||
execute_network_event!(self, RadarrEvent::GetHostConfig);
|
||||
}
|
||||
RadarrGetCommand::MovieDetails { movie_id } => {
|
||||
execute_network_event!(self, RadarrEvent::GetMovieDetails(Some(movie_id)));
|
||||
}
|
||||
RadarrGetCommand::MovieHistory { movie_id } => {
|
||||
execute_network_event!(self, RadarrEvent::GetMovieHistory(Some(movie_id)));
|
||||
}
|
||||
RadarrGetCommand::SecurityConfig => {
|
||||
execute_network_event!(self, RadarrEvent::GetSecurityConfig);
|
||||
}
|
||||
RadarrGetCommand::SystemStatus => {
|
||||
execute_network_event!(self, RadarrEvent::GetStatus);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,14 @@ mod test {
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_host_config_has_no_arg_requirements() {
|
||||
let result =
|
||||
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "host-config"]);
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_movie_details_requires_movie_id() {
|
||||
let result =
|
||||
@@ -81,6 +89,14 @@ mod test {
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_get_security_config_has_no_arg_requirements() {
|
||||
let result =
|
||||
Cli::command().try_get_matches_from(["managarr", "radarr", "get", "security-config"]);
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_system_status_has_no_arg_requirements() {
|
||||
let result =
|
||||
@@ -135,6 +151,29 @@ mod test {
|
||||
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>(RadarrEvent::GetHostConfig.into()))
|
||||
.times(1)
|
||||
.returning(|_| {
|
||||
Ok(Serdeable::Radarr(RadarrSerdeable::Value(
|
||||
json!({"testResponse": "response"}),
|
||||
)))
|
||||
});
|
||||
let app_arc = Arc::new(Mutex::new(App::default()));
|
||||
let get_host_config_command = RadarrGetCommand::HostConfig;
|
||||
|
||||
let result =
|
||||
RadarrGetCommandHandler::with(&app_arc, get_host_config_command, &mut mock_network)
|
||||
.handle()
|
||||
.await;
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_handle_get_movie_details_command() {
|
||||
let expected_movie_id = 1;
|
||||
@@ -187,6 +226,29 @@ mod test {
|
||||
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>(RadarrEvent::GetSecurityConfig.into()))
|
||||
.times(1)
|
||||
.returning(|_| {
|
||||
Ok(Serdeable::Radarr(RadarrSerdeable::Value(
|
||||
json!({"testResponse": "response"}),
|
||||
)))
|
||||
});
|
||||
let app_arc = Arc::new(Mutex::new(App::default()));
|
||||
let get_security_config_command = RadarrGetCommand::SecurityConfig;
|
||||
|
||||
let result =
|
||||
RadarrGetCommandHandler::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