feat(readarr): fetch Readarr queued events and expose them on the CLI

An empty array is a valid response when nothing is queued, so the empty case is covered by its own test.
This commit is contained in:
Dark-Alex-17 committed 2026-08-20 21:52:18 -06:00
1 parent ab3992c372
commit 44d147ce37
6 files changed
+153 -4

No files matched your search

+9
View File
@@ -29,6 +29,8 @@ pub enum ReadarrListCommand {
)]
output_in_log_format: bool,
},
#[command(about = "List all queued events")]
QueuedEvents,
#[command(about = "List all Readarr tasks")]
Tasks,
#[command(about = "List all Readarr updates")]
@@ -86,6 +88,13 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, ReadarrListCommand> for ReadarrListComman
serde_json::to_string_pretty(&logs)?
}
}
ReadarrListCommand::QueuedEvents => {
let resp = self
.network
.handle_network_event(ReadarrEvent::GetQueuedEvents.into())
.await?;
serde_json::to_string_pretty(&resp)?
}
ReadarrListCommand::Tasks => {
let resp = self
.network
+24 -1
View File
@@ -25,7 +25,7 @@ mod tests {
#[rstest]
fn test_list_commands_have_no_arg_requirements(
#[values("disk-space", "tasks", "updates")] subcommand: &str,
#[values("disk-space", "queued-events", "tasks", "updates")] subcommand: &str,
) {
let result = Cli::command().try_get_matches_from(["managarr", "readarr", "list", subcommand]);
@@ -161,6 +161,29 @@ mod tests {
assert_str_eq!(result.unwrap(), "[\n \"readarr log line\"\n]");
}
#[tokio::test]
async fn test_handle_list_queued_events_command() {
let mut mock_network = MockNetworkTrait::new();
mock_network
.expect_handle_network_event()
.with(eq::<NetworkEvent>(ReadarrEvent::GetQueuedEvents.into()))
.times(1)
.returning(|_| {
Ok(Serdeable::Readarr(ReadarrSerdeable::Value(
json!({"testResponse": "response"}),
)))
});
let app_arc = Arc::new(Mutex::new(App::test_default()));
let list_queued_events_command = ReadarrListCommand::QueuedEvents;
let result =
ReadarrListCommandHandler::with(&app_arc, list_queued_events_command, &mut mock_network)
.handle()
.await;
assert_ok!(&result);
}
#[tokio::test]
async fn test_handle_list_tasks_command() {
let mut mock_network = MockNetworkTrait::new();