feat(cli): Support for testing all Sonarr indexers at once
This commit is contained in:
@@ -116,7 +116,7 @@ pub enum RadarrCommand {
|
|||||||
#[arg(long, help = "The ID of the indexer to test", required = true)]
|
#[arg(long, help = "The ID of the indexer to test", required = true)]
|
||||||
indexer_id: i64,
|
indexer_id: i64,
|
||||||
},
|
},
|
||||||
#[command(about = "Test all indexers")]
|
#[command(about = "Test all Radarr indexers")]
|
||||||
TestAllIndexers,
|
TestAllIndexers,
|
||||||
#[command(about = "Trigger an automatic search for the movie with the specified ID")]
|
#[command(about = "Trigger an automatic search for the movie with the specified ID")]
|
||||||
TriggerAutomaticSearch {
|
TriggerAutomaticSearch {
|
||||||
@@ -243,6 +243,7 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, RadarrCommand> for RadarrCliHandler<'a, '
|
|||||||
serde_json::to_string_pretty(&resp)?
|
serde_json::to_string_pretty(&resp)?
|
||||||
}
|
}
|
||||||
RadarrCommand::TestAllIndexers => {
|
RadarrCommand::TestAllIndexers => {
|
||||||
|
println!("Testing all Radarr indexers. This may take a minute...");
|
||||||
let resp = self
|
let resp = self
|
||||||
.network
|
.network
|
||||||
.handle_network_event(RadarrEvent::TestAllIndexers.into())
|
.handle_network_event(RadarrEvent::TestAllIndexers.into())
|
||||||
|
|||||||
@@ -97,6 +97,8 @@ pub enum SonarrCommand {
|
|||||||
#[arg(long, help = "The ID of the indexer to test", required = true)]
|
#[arg(long, help = "The ID of the indexer to test", required = true)]
|
||||||
indexer_id: i64,
|
indexer_id: i64,
|
||||||
},
|
},
|
||||||
|
#[command(about = "Test all Radarr indexers")]
|
||||||
|
TestAllIndexers,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SonarrCommand> for Command {
|
impl From<SonarrCommand> for Command {
|
||||||
@@ -199,6 +201,14 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, SonarrCommand> for SonarrCliHandler<'a, '
|
|||||||
.await?;
|
.await?;
|
||||||
serde_json::to_string_pretty(&resp)?
|
serde_json::to_string_pretty(&resp)?
|
||||||
}
|
}
|
||||||
|
SonarrCommand::TestAllIndexers => {
|
||||||
|
println!("Testing all Sonarr indexers. This may take a minute...");
|
||||||
|
let resp = self
|
||||||
|
.network
|
||||||
|
.handle_network_event(SonarrEvent::TestAllIndexers.into())
|
||||||
|
.await?;
|
||||||
|
serde_json::to_string_pretty(&resp)?
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
|||||||
@@ -22,7 +22,9 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
fn test_commands_that_have_no_arg_requirements(#[values("clear-blocklist")] subcommand: &str) {
|
fn test_commands_that_have_no_arg_requirements(
|
||||||
|
#[values("clear-blocklist", "test-all-indexers")] subcommand: &str,
|
||||||
|
) {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", subcommand]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", subcommand]);
|
||||||
|
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
@@ -486,5 +488,27 @@ mod tests {
|
|||||||
|
|
||||||
assert!(result.is_ok());
|
assert!(result.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn test_test_all_indexers_command() {
|
||||||
|
let mut mock_network = MockNetworkTrait::new();
|
||||||
|
mock_network
|
||||||
|
.expect_handle_network_event()
|
||||||
|
.with(eq::<NetworkEvent>(SonarrEvent::TestAllIndexers.into()))
|
||||||
|
.times(1)
|
||||||
|
.returning(|_| {
|
||||||
|
Ok(Serdeable::Sonarr(SonarrSerdeable::Value(
|
||||||
|
json!({"testResponse": "response"}),
|
||||||
|
)))
|
||||||
|
});
|
||||||
|
let app_arc = Arc::new(Mutex::new(App::default()));
|
||||||
|
let test_all_indexers_command = SonarrCommand::TestAllIndexers;
|
||||||
|
|
||||||
|
let result = SonarrCliHandler::with(&app_arc, test_all_indexers_command, &mut mock_network)
|
||||||
|
.handle()
|
||||||
|
.await;
|
||||||
|
|
||||||
|
assert!(result.is_ok());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user