feat(readarr): search for new Readarr authors and expose the command on the CLI

This commit is contained in:
Dark-Alex-17 committed 2026-08-26 16:57:26 -06:00
1 parent 5042dbdb3a
commit 9238c1b9d2
7 files changed
+244 -4

No files matched your search

+52
View File
@@ -14,6 +14,31 @@ mod tests {
assert_err!(&result);
}
#[test]
fn test_search_new_author_requires_query() {
let result =
Cli::command().try_get_matches_from(["managarr", "readarr", "search-new-author"]);
assert_err!(&result);
assert_eq!(
result.unwrap_err().kind(),
ErrorKind::MissingRequiredArgument
);
}
#[test]
fn test_search_new_author_requirements_satisfied() {
let result = Cli::command().try_get_matches_from([
"managarr",
"readarr",
"search-new-author",
"--query",
"test query",
]);
assert_ok!(&result);
}
#[test]
fn test_start_task_requires_task_name() {
let result = Cli::command().try_get_matches_from(["managarr", "readarr", "start-task"]);
@@ -71,6 +96,33 @@ mod tests {
network::{MockNetworkTrait, NetworkEvent, readarr_network::ReadarrEvent},
};
#[tokio::test]
async fn test_search_new_author_command() {
let expected_query = "test author".to_owned();
let mut mock_network = MockNetworkTrait::new();
mock_network
.expect_handle_network_event()
.with(eq::<NetworkEvent>(
ReadarrEvent::SearchNewAuthor(expected_query.clone()).into(),
))
.times(1)
.returning(|_| {
Ok(Serdeable::Readarr(ReadarrSerdeable::Value(
json!({"testResponse": "response"}),
)))
});
let app_arc = Arc::new(Mutex::new(App::test_default()));
let search_new_author_command = ReadarrCommand::SearchNewAuthor {
query: expected_query,
};
let result = ReadarrCliHandler::with(&app_arc, search_new_author_command, &mut mock_network)
.handle()
.await;
assert_ok!(&result);
}
#[tokio::test]
async fn test_start_task_command() {
let expected_task_name = ReadarrTaskName::CheckHealth;