feat: Fixed the Radarr downloads tab to display more than 10 downloads at a time and added a new --count flag to the CLI for specifying the number of downloads to return
This commit is contained in:
@@ -23,7 +23,10 @@ pub enum RadarrListCommand {
|
||||
#[command(about = "List all Radarr collections")]
|
||||
Collections,
|
||||
#[command(about = "List all active downloads in Radarr")]
|
||||
Downloads,
|
||||
Downloads {
|
||||
#[arg(long, help = "How many downloads to fetch", default_value_t = 500)]
|
||||
count: u64,
|
||||
},
|
||||
#[command(about = "List disk space details for all provisioned root folders in Radarr")]
|
||||
DiskSpace,
|
||||
#[command(about = "List all Radarr indexers")]
|
||||
@@ -104,10 +107,10 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, RadarrListCommand> for RadarrListCommandH
|
||||
.await?;
|
||||
serde_json::to_string_pretty(&resp)?
|
||||
}
|
||||
RadarrListCommand::Downloads => {
|
||||
RadarrListCommand::Downloads { count } => {
|
||||
let resp = self
|
||||
.network
|
||||
.handle_network_event(RadarrEvent::GetDownloads.into())
|
||||
.handle_network_event(RadarrEvent::GetDownloads(count).into())
|
||||
.await?;
|
||||
serde_json::to_string_pretty(&resp)?
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ mod tests {
|
||||
#[values(
|
||||
"blocklist",
|
||||
"collections",
|
||||
"downloads",
|
||||
"disk-space",
|
||||
"indexers",
|
||||
"movies",
|
||||
@@ -59,6 +58,15 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_list_downloads_count_flag_requires_arguments() {
|
||||
let result =
|
||||
Cli::command().try_get_matches_from(["managarr", "radarr", "list", "downloads", "--count"]);
|
||||
|
||||
assert!(result.is_err());
|
||||
assert_eq!(result.unwrap_err().kind(), ErrorKind::InvalidValue);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_list_logs_events_flag_requires_arguments() {
|
||||
let result =
|
||||
@@ -87,6 +95,18 @@ mod tests {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_list_downloads_default_values() {
|
||||
let expected_args = RadarrListCommand::Downloads { count: 500 };
|
||||
let result = Cli::try_parse_from(["managarr", "radarr", "list", "downloads"]);
|
||||
|
||||
assert!(result.is_ok());
|
||||
|
||||
if let Some(Command::Radarr(RadarrCommand::List(refresh_command))) = result.unwrap().command {
|
||||
assert_eq!(refresh_command, expected_args);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_list_logs_default_values() {
|
||||
let expected_args = RadarrListCommand::Logs {
|
||||
@@ -122,7 +142,6 @@ mod tests {
|
||||
#[rstest]
|
||||
#[case(RadarrListCommand::Blocklist, RadarrEvent::GetBlocklist)]
|
||||
#[case(RadarrListCommand::Collections, RadarrEvent::GetCollections)]
|
||||
#[case(RadarrListCommand::Downloads, RadarrEvent::GetDownloads)]
|
||||
#[case(RadarrListCommand::DiskSpace, RadarrEvent::GetDiskSpace)]
|
||||
#[case(RadarrListCommand::Indexers, RadarrEvent::GetIndexers)]
|
||||
#[case(RadarrListCommand::Movies, RadarrEvent::GetMovies)]
|
||||
@@ -182,6 +201,32 @@ mod tests {
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_handle_list_downloads_command() {
|
||||
let expected_count = 1000;
|
||||
let mut mock_network = MockNetworkTrait::new();
|
||||
mock_network
|
||||
.expect_handle_network_event()
|
||||
.with(eq::<NetworkEvent>(
|
||||
RadarrEvent::GetDownloads(expected_count).into(),
|
||||
))
|
||||
.times(1)
|
||||
.returning(|_| {
|
||||
Ok(Serdeable::Radarr(RadarrSerdeable::Value(
|
||||
json!({"testResponse": "response"}),
|
||||
)))
|
||||
});
|
||||
let app_arc = Arc::new(Mutex::new(App::test_default()));
|
||||
let list_downloads_command = RadarrListCommand::Downloads { count: 1000 };
|
||||
|
||||
let result =
|
||||
RadarrListCommandHandler::with(&app_arc, list_downloads_command, &mut mock_network)
|
||||
.handle()
|
||||
.await;
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_handle_list_logs_command() {
|
||||
let expected_events = 1000;
|
||||
|
||||
@@ -102,7 +102,7 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_list_downloads_events_flag_requires_arguments() {
|
||||
fn test_list_downloads_count_flag_requires_arguments() {
|
||||
let result =
|
||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "list", "downloads", "--count"]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user