fix(sonarr): Pass the indexer ID directly alongside all TestIndexer events when publishing to the networking channel

This commit is contained in:
2024-12-18 01:01:01 -07:00
parent 42479ced21
commit 1d404d4d2c
8 changed files with 43 additions and 90 deletions
+4 -2
View File
@@ -77,7 +77,9 @@ impl<'a> App<'a> {
}
ActiveRadarrBlock::TestIndexer => {
self
.dispatch_network_event(RadarrEvent::TestIndexer(self.extract_indexer_id().await).into())
.dispatch_network_event(
RadarrEvent::TestIndexer(self.extract_radarr_indexer_id().await).into(),
)
.await;
}
ActiveRadarrBlock::TestAllIndexers => {
@@ -243,7 +245,7 @@ impl<'a> App<'a> {
.clone()
}
async fn extract_indexer_id(&self) -> i64 {
async fn extract_radarr_indexer_id(&self) -> i64 {
self
.data
.radarr_data
+2 -2
View File
@@ -769,14 +769,14 @@ mod tests {
}
#[tokio::test]
async fn test_extract_indexer_id() {
async fn test_extract_radarr_indexer_id() {
let mut app = App::default();
app.data.radarr_data.indexers.set_items(vec![Indexer {
id: 1,
..Indexer::default()
}]);
assert_eq!(app.extract_indexer_id().await, 1);
assert_eq!(app.extract_radarr_indexer_id().await, 1);
}
fn construct_app_unit<'a>() -> (App<'a>, mpsc::Receiver<NetworkEvent>) {
+7 -1
View File
@@ -144,7 +144,9 @@ impl<'a> App<'a> {
}
ActiveSonarrBlock::TestIndexer => {
self
.dispatch_network_event(SonarrEvent::TestIndexer(None).into())
.dispatch_network_event(
SonarrEvent::TestIndexer(self.extract_sonarr_indexer_id().await).into(),
)
.await;
}
ActiveSonarrBlock::TestAllIndexers => {
@@ -300,4 +302,8 @@ impl<'a> App<'a> {
.text
.clone()
}
async fn extract_sonarr_indexer_id(&self) -> i64 {
self.data.sonarr_data.indexers.current_selection().id
}
}
+17 -1
View File
@@ -5,6 +5,7 @@ mod tests {
use tokio::sync::mpsc;
use crate::models::servarr_data::sonarr::sonarr_data::sonarr_test_utils::utils::create_test_sonarr_data;
use crate::models::servarr_models::Indexer;
use crate::models::sonarr_models::Episode;
use crate::{
app::App,
@@ -458,6 +459,10 @@ mod tests {
#[tokio::test]
async fn test_dispatch_by_test_indexer_block() {
let (mut app, mut sync_network_rx) = construct_app_unit();
app.data.sonarr_data.indexers.set_items(vec![Indexer {
id: 1,
..Indexer::default()
}]);
app
.dispatch_by_sonarr_block(&ActiveSonarrBlock::TestIndexer)
@@ -466,7 +471,7 @@ mod tests {
assert!(app.is_loading);
assert_eq!(
sync_network_rx.recv().await.unwrap(),
SonarrEvent::TestIndexer(None).into()
SonarrEvent::TestIndexer(1).into()
);
assert_eq!(app.tick_count, 0);
}
@@ -849,6 +854,17 @@ mod tests {
app.extract_add_new_series_search_query().await;
}
#[tokio::test]
async fn test_extract_sonarr_indexer_id() {
let mut app = App::default();
app.data.sonarr_data.indexers.set_items(vec![Indexer {
id: 1,
..Indexer::default()
}]);
assert_eq!(app.extract_sonarr_indexer_id().await, 1);
}
fn construct_app_unit<'a>() -> (App<'a>, mpsc::Receiver<NetworkEvent>) {
let (sync_network_tx, sync_network_rx) = mpsc::channel::<NetworkEvent>(500);
let mut app = App {