feat(readarr): fetch the blocklist and expose it on the CLI
This commit is contained in:
7 files changed
+334
-3
No files matched your search
@@ -37,6 +37,8 @@ pub enum ReadarrListCommand {
|
||||
},
|
||||
#[command(about = "List all authors in your Readarr library")]
|
||||
Authors,
|
||||
#[command(about = "List all items in the Readarr blocklist")]
|
||||
Blocklist,
|
||||
#[command(about = "List all editions for the book with the given ID")]
|
||||
BookEditions {
|
||||
#[arg(
|
||||
@@ -175,6 +177,13 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, ReadarrListCommand> for ReadarrListComman
|
||||
.await?;
|
||||
serde_json::to_string_pretty(&resp)?
|
||||
}
|
||||
ReadarrListCommand::Blocklist => {
|
||||
let resp = self
|
||||
.network
|
||||
.handle_network_event(ReadarrEvent::GetBlocklist.into())
|
||||
.await?;
|
||||
serde_json::to_string_pretty(&resp)?
|
||||
}
|
||||
ReadarrListCommand::BookEditions { book_id } => {
|
||||
let resp = self
|
||||
.network
|
||||
|
||||
@@ -27,6 +27,7 @@ mod tests {
|
||||
fn test_list_commands_have_no_arg_requirements(
|
||||
#[values(
|
||||
"authors",
|
||||
"blocklist",
|
||||
"disk-space",
|
||||
"metadata-profiles",
|
||||
"quality-profiles",
|
||||
@@ -424,6 +425,29 @@ mod tests {
|
||||
assert_ok!(&result);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_handle_list_blocklist_command() {
|
||||
let mut mock_network = MockNetworkTrait::new();
|
||||
mock_network
|
||||
.expect_handle_network_event()
|
||||
.with(eq::<NetworkEvent>(ReadarrEvent::GetBlocklist.into()))
|
||||
.times(1)
|
||||
.returning(|_| {
|
||||
Ok(Serdeable::Readarr(ReadarrSerdeable::Value(
|
||||
json!({"testResponse": "response"}),
|
||||
)))
|
||||
});
|
||||
let app_arc = Arc::new(Mutex::new(App::test_default()));
|
||||
let list_blocklist_command = ReadarrListCommand::Blocklist;
|
||||
|
||||
let result =
|
||||
ReadarrListCommandHandler::with(&app_arc, list_blocklist_command, &mut mock_network)
|
||||
.handle()
|
||||
.await;
|
||||
|
||||
assert_ok!(&result);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_handle_list_author_history_command() {
|
||||
let expected_author_id = 1;
|
||||
|
||||
Reference in new issue
Block a user