feat(cli): CLI support for adding a tag to Sonarr

This commit is contained in:
2024-11-22 15:22:45 -07:00
parent c5328917de
commit 1cc95e2cd1
5 changed files with 208 additions and 5 deletions
+30 -2
View File
@@ -114,8 +114,9 @@ mod tests {
app::App,
cli::{
sonarr::{
delete_command_handler::SonarrDeleteCommand, get_command_handler::SonarrGetCommand,
list_command_handler::SonarrListCommand, SonarrCliHandler, SonarrCommand,
add_command_handler::SonarrAddCommand, delete_command_handler::SonarrDeleteCommand,
get_command_handler::SonarrGetCommand, list_command_handler::SonarrListCommand,
SonarrCliHandler, SonarrCommand,
},
CliCommandHandler,
},
@@ -215,6 +216,33 @@ mod tests {
assert!(result.is_ok());
}
#[tokio::test]
async fn test_sonarr_cli_handler_delegates_add_commands_to_the_add_command_handler() {
let expected_tag_name = "test".to_owned();
let mut mock_network = MockNetworkTrait::new();
mock_network
.expect_handle_network_event()
.with(eq::<NetworkEvent>(
SonarrEvent::AddTag(expected_tag_name.clone()).into(),
))
.times(1)
.returning(|_| {
Ok(Serdeable::Sonarr(SonarrSerdeable::Value(
json!({"testResponse": "response"}),
)))
});
let app_arc = Arc::new(Mutex::new(App::default()));
let add_tag_command = SonarrCommand::Add(SonarrAddCommand::Tag {
name: expected_tag_name,
});
let result = SonarrCliHandler::with(&app_arc, add_tag_command, &mut mock_network)
.handle()
.await;
assert!(result.is_ok());
}
#[tokio::test]
async fn test_sonarr_cli_handler_delegates_delete_commands_to_the_delete_command_handler() {
let expected_blocklist_item_id = 1;