fix(sonarr): Pass the series ID alongside all UpdateAndScan events when publishing to the networking channel
This commit is contained in:
@@ -71,7 +71,7 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, SonarrRefreshCommand>
|
||||
SonarrRefreshCommand::Series { series_id } => {
|
||||
let resp = self
|
||||
.network
|
||||
.handle_network_event(SonarrEvent::UpdateAndScanSeries(Some(series_id)).into())
|
||||
.handle_network_event(SonarrEvent::UpdateAndScanSeries(series_id).into())
|
||||
.await?;
|
||||
serde_json::to_string_pretty(&resp)?
|
||||
}
|
||||
|
||||
@@ -119,7 +119,7 @@ mod tests {
|
||||
mock_network
|
||||
.expect_handle_network_event()
|
||||
.with(eq::<NetworkEvent>(
|
||||
SonarrEvent::UpdateAndScanSeries(Some(expected_series_id)).into(),
|
||||
SonarrEvent::UpdateAndScanSeries(expected_series_id).into(),
|
||||
))
|
||||
.times(1)
|
||||
.returning(|_| {
|
||||
|
||||
@@ -571,7 +571,7 @@ mod tests {
|
||||
mock_network
|
||||
.expect_handle_network_event()
|
||||
.with(eq::<NetworkEvent>(
|
||||
SonarrEvent::UpdateAndScanSeries(Some(expected_series_id)).into(),
|
||||
SonarrEvent::UpdateAndScanSeries(expected_series_id).into(),
|
||||
))
|
||||
.times(1)
|
||||
.returning(|_| {
|
||||
|
||||
@@ -195,7 +195,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeriesDetailsHandler
|
||||
ActiveSonarrBlock::UpdateAndScanSeriesPrompt => {
|
||||
if self.app.data.sonarr_data.prompt_confirm {
|
||||
self.app.data.sonarr_data.prompt_confirm_action =
|
||||
Some(SonarrEvent::UpdateAndScanSeries(None));
|
||||
Some(SonarrEvent::UpdateAndScanSeries(self.extract_series_id()));
|
||||
}
|
||||
|
||||
self.app.pop_navigation_stack();
|
||||
@@ -328,7 +328,7 @@ impl<'a, 'b> KeyEventHandler<'a, 'b, ActiveSonarrBlock> for SeriesDetailsHandler
|
||||
ActiveSonarrBlock::UpdateAndScanSeriesPrompt => {
|
||||
if self.app.data.sonarr_data.prompt_confirm {
|
||||
self.app.data.sonarr_data.prompt_confirm_action =
|
||||
Some(SonarrEvent::UpdateAndScanSeries(None));
|
||||
Some(SonarrEvent::UpdateAndScanSeries(self.extract_series_id()));
|
||||
}
|
||||
|
||||
self.app.pop_navigation_stack();
|
||||
|
||||
@@ -187,7 +187,7 @@ mod tests {
|
||||
)]
|
||||
#[case(
|
||||
ActiveSonarrBlock::UpdateAndScanSeriesPrompt,
|
||||
SonarrEvent::UpdateAndScanSeries(None)
|
||||
SonarrEvent::UpdateAndScanSeries(1)
|
||||
)]
|
||||
fn test_series_details_prompt_confirm_submit(
|
||||
#[case] prompt_block: ActiveSonarrBlock,
|
||||
@@ -572,7 +572,7 @@ mod tests {
|
||||
)]
|
||||
#[case(
|
||||
ActiveSonarrBlock::UpdateAndScanSeriesPrompt,
|
||||
SonarrEvent::UpdateAndScanSeries(None)
|
||||
SonarrEvent::UpdateAndScanSeries(1)
|
||||
)]
|
||||
fn test_series_details_prompt_confirm_confirm_key(
|
||||
#[case] prompt_block: ActiveSonarrBlock,
|
||||
|
||||
@@ -92,7 +92,7 @@ pub enum SonarrEvent {
|
||||
TriggerAutomaticSeasonSearch((i64, i64)),
|
||||
TriggerAutomaticSeriesSearch(i64),
|
||||
UpdateAllSeries,
|
||||
UpdateAndScanSeries(Option<i64>),
|
||||
UpdateAndScanSeries(i64),
|
||||
UpdateDownloads,
|
||||
}
|
||||
|
||||
@@ -2257,13 +2257,12 @@ impl<'a, 'b> Network<'a, 'b> {
|
||||
.await
|
||||
}
|
||||
|
||||
async fn update_and_scan_series(&mut self, series_id: Option<i64>) -> Result<Value> {
|
||||
let (id, _) = self.extract_series_id(series_id).await;
|
||||
let event = SonarrEvent::UpdateAndScanSeries(None);
|
||||
info!("Updating and scanning series with ID: {id}");
|
||||
async fn update_and_scan_series(&mut self, series_id: i64) -> Result<Value> {
|
||||
let event = SonarrEvent::UpdateAndScanSeries(series_id);
|
||||
info!("Updating and scanning series with ID: {series_id}");
|
||||
let body = SonarrCommandBody {
|
||||
name: "RefreshSeries".to_owned(),
|
||||
series_id: Some(id),
|
||||
series_id: Some(series_id),
|
||||
..SonarrCommandBody::default()
|
||||
};
|
||||
|
||||
|
||||
@@ -197,7 +197,7 @@ mod test {
|
||||
SonarrEvent::TriggerAutomaticSeasonSearch((0, 0)),
|
||||
SonarrEvent::TriggerAutomaticSeriesSearch(0),
|
||||
SonarrEvent::UpdateAllSeries,
|
||||
SonarrEvent::UpdateAndScanSeries(None),
|
||||
SonarrEvent::UpdateAndScanSeries(0),
|
||||
SonarrEvent::UpdateDownloads
|
||||
)]
|
||||
event: SonarrEvent,
|
||||
@@ -5241,7 +5241,7 @@ mod test {
|
||||
})),
|
||||
Some(json!({})),
|
||||
None,
|
||||
SonarrEvent::UpdateAndScanSeries(None),
|
||||
SonarrEvent::UpdateAndScanSeries(1),
|
||||
None,
|
||||
None,
|
||||
)
|
||||
@@ -5256,32 +5256,7 @@ mod test {
|
||||
let mut network = Network::new(&app_arc, CancellationToken::new(), Client::new());
|
||||
|
||||
assert!(network
|
||||
.handle_sonarr_event(SonarrEvent::UpdateAndScanSeries(None))
|
||||
.await
|
||||
.is_ok());
|
||||
|
||||
async_server.assert_async().await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_handle_update_and_scan_series_event_uses_provied_series_id() {
|
||||
let (async_server, app_arc, _server) = mock_servarr_api(
|
||||
RequestMethod::Post,
|
||||
Some(json!({
|
||||
"name": "RefreshSeries",
|
||||
"seriesId": 1
|
||||
})),
|
||||
Some(json!({})),
|
||||
None,
|
||||
SonarrEvent::UpdateAndScanSeries(Some(1)),
|
||||
None,
|
||||
None,
|
||||
)
|
||||
.await;
|
||||
let mut network = Network::new(&app_arc, CancellationToken::new(), Client::new());
|
||||
|
||||
assert!(network
|
||||
.handle_sonarr_event(SonarrEvent::UpdateAndScanSeries(Some(1)))
|
||||
.handle_sonarr_event(SonarrEvent::UpdateAndScanSeries(1))
|
||||
.await
|
||||
.is_ok());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user