feat(cli): Support for searching for new series to add to Sonarr
This commit is contained in:
@@ -57,6 +57,30 @@ mod tests {
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_search_new_series_requires_query() {
|
||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "search-new-series"]);
|
||||
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.unwrap_err().kind(),
|
||||
ErrorKind::MissingRequiredArgument
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_search_new_series_requirements_satisfied() {
|
||||
let result = Cli::command().try_get_matches_from([
|
||||
"managarr",
|
||||
"sonarr",
|
||||
"search-new-series",
|
||||
"--query",
|
||||
"halo",
|
||||
]);
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_start_task_requires_task_name() {
|
||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "start-task"]);
|
||||
@@ -434,6 +458,33 @@ mod tests {
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_search_new_series_command() {
|
||||
let expected_search_query = "halo".to_owned();
|
||||
let mut mock_network = MockNetworkTrait::new();
|
||||
mock_network
|
||||
.expect_handle_network_event()
|
||||
.with(eq::<NetworkEvent>(
|
||||
SonarrEvent::SearchNewSeries(Some(expected_search_query)).into(),
|
||||
))
|
||||
.times(1)
|
||||
.returning(|_| {
|
||||
Ok(Serdeable::Sonarr(SonarrSerdeable::Value(
|
||||
json!({"testResponse": "response"}),
|
||||
)))
|
||||
});
|
||||
let app_arc = Arc::new(Mutex::new(App::default()));
|
||||
let search_new_series_command = SonarrCommand::SearchNewSeries {
|
||||
query: "halo".to_owned(),
|
||||
};
|
||||
|
||||
let result = SonarrCliHandler::with(&app_arc, search_new_series_command, &mut mock_network)
|
||||
.handle()
|
||||
.await;
|
||||
|
||||
assert!(result.is_ok());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_start_task_command() {
|
||||
let expected_task_name = SonarrTaskName::ApplicationUpdateCheck;
|
||||
|
||||
Reference in New Issue
Block a user