feat(readarr): fetch Readarr book editions and expose them on the CLI

This commit is contained in:
Dark-Alex-17 committed 2026-08-27 14:58:47 -06:00
1 parent 817ebeaf90
commit 4c6a9ece4e
7 files changed
+330 -4

No files matched your search

@@ -96,6 +96,40 @@ mod tests {
);
}
#[test]
fn test_list_book_editions_requires_book_id() {
let result =
Cli::command().try_get_matches_from(["managarr", "readarr", "list", "book-editions"]);
assert_err!(&result);
assert_eq!(
result.unwrap_err().kind(),
ErrorKind::MissingRequiredArgument
);
}
#[test]
fn test_list_book_editions_success() {
let expected_args = ReadarrListCommand::BookEditions { book_id: 1 };
let result = Cli::try_parse_from([
"managarr",
"readarr",
"list",
"book-editions",
"--book-id",
"1",
]);
assert_ok!(&result);
let Some(Command::Readarr(ReadarrCommand::List(book_editions_command))) =
result.unwrap().command
else {
panic!("Unexpected command type");
};
assert_eq!(book_editions_command, expected_args);
}
#[test]
fn test_list_books_success() {
let expected_args = ReadarrListCommand::Books { author_id: 1 };
@@ -221,6 +255,32 @@ mod tests {
assert_ok!(&result);
}
#[tokio::test]
async fn test_handle_list_book_editions_command() {
let expected_book_id = 1;
let mut mock_network = MockNetworkTrait::new();
mock_network
.expect_handle_network_event()
.with(eq::<NetworkEvent>(
ReadarrEvent::GetBookEditions(expected_book_id).into(),
))
.times(1)
.returning(|_| {
Ok(Serdeable::Readarr(ReadarrSerdeable::Value(
json!({"testResponse": "response"}),
)))
});
let app_arc = Arc::new(Mutex::new(App::test_default()));
let list_book_editions_command = ReadarrListCommand::BookEditions { book_id: 1 };
let result =
ReadarrListCommandHandler::with(&app_arc, list_book_editions_command, &mut mock_network)
.handle()
.await;
assert_ok!(&result);
}
#[tokio::test]
async fn test_handle_list_disk_space_command() {
let mut mock_network = MockNetworkTrait::new();