feat(readarr): fetch releases for a book and expose them on the CLI

This commit is contained in:
Dark-Alex-17 committed 2026-08-28 14:07:15 -06:00
1 parent 1edceba056
commit 666084a30f
7 files changed
+333 -4

No files matched your search

@@ -241,6 +241,32 @@ mod tests {
assert_eq!(books_command, expected_args);
}
#[test]
fn test_list_releases_requires_book_id() {
let result = Cli::command().try_get_matches_from(["managarr", "readarr", "list", "releases"]);
assert_err!(&result);
assert_eq!(
result.unwrap_err().kind(),
ErrorKind::MissingRequiredArgument
);
}
#[test]
fn test_list_releases_success() {
let expected_args = ReadarrListCommand::Releases { book_id: 7 };
let result =
Cli::try_parse_from(["managarr", "readarr", "list", "releases", "--book-id", "7"]);
assert_ok!(&result);
let Some(Command::Readarr(ReadarrCommand::List(releases_command))) = result.unwrap().command
else {
panic!("Unexpected command type");
};
assert_eq!(releases_command, expected_args);
}
#[test]
fn test_list_logs_default_values() {
let expected_args = ReadarrListCommand::Logs {
@@ -705,6 +731,32 @@ mod tests {
assert_ok!(&result);
}
#[tokio::test]
async fn test_handle_list_releases_command() {
let expected_book_id = 7;
let mut mock_network = MockNetworkTrait::new();
mock_network
.expect_handle_network_event()
.with(eq::<NetworkEvent>(
ReadarrEvent::GetBookReleases(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_releases_command = ReadarrListCommand::Releases { book_id: 7 };
let result =
ReadarrListCommandHandler::with(&app_arc, list_releases_command, &mut mock_network)
.handle()
.await;
assert_ok!(&result);
}
#[tokio::test]
async fn test_handle_list_root_folders_command() {
let mut mock_network = MockNetworkTrait::new();