feat(cli): Support for toggling monitoring on a specific episode in Sonarr

This commit is contained in:
2024-12-13 14:49:00 -07:00
parent 4001dee1bd
commit a28f8c3dd2
2 changed files with 74 additions and 0 deletions
+56
View File
@@ -143,6 +143,34 @@ mod tests {
assert!(result.is_ok());
}
#[test]
fn test_toggle_episode_monitoring_requires_episode_id() {
let result = Cli::command().try_get_matches_from([
"managarr",
"sonarr",
"toggle-episode-monitoring",
]);
assert!(result.is_err());
assert_eq!(
result.unwrap_err().kind(),
ErrorKind::MissingRequiredArgument
);
}
#[test]
fn test_toggle_episode_monitoring_requirements_satisfied() {
let result = Cli::command().try_get_matches_from([
"managarr",
"sonarr",
"toggle-episode-monitoring",
"--episode-id",
"1",
]);
assert!(result.is_ok());
}
#[test]
fn test_toggle_season_monitoring_requires_series_id() {
let result = Cli::command().try_get_matches_from([
@@ -666,6 +694,34 @@ mod tests {
assert!(result.is_ok());
}
#[tokio::test]
async fn test_list_toggle_episode_monitoring_command() {
let expected_episode_id = 1;
let mut mock_network = MockNetworkTrait::new();
mock_network
.expect_handle_network_event()
.with(eq::<NetworkEvent>(
SonarrEvent::ToggleEpisodeMonitoring(Some(expected_episode_id)).into(),
))
.times(1)
.returning(|_| {
Ok(Serdeable::Sonarr(SonarrSerdeable::Value(
json!({"testResponse": "response"}),
)))
});
let app_arc = Arc::new(Mutex::new(App::default()));
let toggle_episode_monitoring_command = SonarrCommand::ToggleEpisodeMonitoring {
episode_id: 1,
};
let result =
SonarrCliHandler::with(&app_arc, toggle_episode_monitoring_command, &mut mock_network)
.handle()
.await;
assert!(result.is_ok());
}
#[tokio::test]
async fn test_list_toggle_season_monitoring_command() {
let expected_series_id = 1;