feat(cli): Support for refreshing a specific series in Sonarr

This commit is contained in:
2024-11-22 19:13:57 -07:00
parent c3577a0724
commit eb06787bb2
3 changed files with 100 additions and 27 deletions
+24 -24
View File
@@ -312,7 +312,7 @@ mod tests {
sonarr::{
add_command_handler::SonarrAddCommand, delete_command_handler::SonarrDeleteCommand,
get_command_handler::SonarrGetCommand, list_command_handler::SonarrListCommand,
SonarrCliHandler, SonarrCommand,
refresh_command_handler::SonarrRefreshCommand, SonarrCliHandler, SonarrCommand,
},
CliCommandHandler,
},
@@ -544,31 +544,31 @@ mod tests {
assert!(result.is_ok());
}
// #[tokio::test]
// async fn test_sonarr_cli_handler_delegates_refresh_commands_to_the_refresh_command_handler() {
// let expected_series_id = 1;
// let mut mock_network = MockNetworkTrait::new();
// mock_network
// .expect_handle_network_event()
// .with(eq::<NetworkEvent>(
// SonarrEvent::UpdateAndScan(Some(expected_movie_id)).into(),
// ))
// .times(1)
// .returning(|_| {
// Ok(Serdeable::Sonarr(SonarrSerdeable::Value(
// json!({"testResponse": "response"}),
// )))
// });
// let app_arc = Arc::new(Mutex::new(App::default()));
// let refresh_all_series_command =
// SonarrCommand::Refresh(SonarrRefreshCommand::Movie { movie_id: 1 });
#[tokio::test]
async fn test_sonarr_cli_handler_delegates_refresh_commands_to_the_refresh_command_handler() {
let expected_series_id = 1;
let mut mock_network = MockNetworkTrait::new();
mock_network
.expect_handle_network_event()
.with(eq::<NetworkEvent>(
SonarrEvent::UpdateAndScanSeries(Some(expected_series_id)).into(),
))
.times(1)
.returning(|_| {
Ok(Serdeable::Sonarr(SonarrSerdeable::Value(
json!({"testResponse": "response"}),
)))
});
let app_arc = Arc::new(Mutex::new(App::default()));
let refresh_series_command =
SonarrCommand::Refresh(SonarrRefreshCommand::Series { series_id: 1 });
// let result = SonarrCliHandler::with(&app_arc, refresh_movie_command, &mut mock_network)
// .handle()
// .await;
let result = SonarrCliHandler::with(&app_arc, refresh_series_command, &mut mock_network)
.handle()
.await;
// assert!(result.is_ok());
// }
assert!(result.is_ok());
}
#[tokio::test]
async fn test_start_task_command() {