test: Updated Rust edition to 2024 and refactored network module tests to be more idiomatic
This commit is contained in:
@@ -10,7 +10,7 @@ use crate::{
|
||||
app::App,
|
||||
cli::{CliCommandHandler, Command},
|
||||
models::sonarr_models::{AddSeriesBody, AddSeriesOptions, SeriesMonitor, SeriesType},
|
||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
||||
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use clap::{error::ErrorKind, CommandFactory, Parser};
|
||||
use clap::{CommandFactory, Parser, error::ErrorKind};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::{
|
||||
cli::{
|
||||
sonarr::{add_command_handler::SonarrAddCommand, SonarrCommand},
|
||||
Command,
|
||||
},
|
||||
Cli,
|
||||
cli::{
|
||||
Command,
|
||||
sonarr::{SonarrCommand, add_command_handler::SonarrAddCommand},
|
||||
},
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -456,14 +456,14 @@ mod tests {
|
||||
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{sonarr::add_command_handler::SonarrAddCommandHandler, CliCommandHandler},
|
||||
cli::{CliCommandHandler, sonarr::add_command_handler::SonarrAddCommandHandler},
|
||||
models::{
|
||||
Serdeable,
|
||||
sonarr_models::{
|
||||
AddSeriesBody, AddSeriesOptions, SeriesMonitor, SeriesType, SonarrSerdeable,
|
||||
},
|
||||
Serdeable,
|
||||
},
|
||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
||||
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{
|
||||
app::App,
|
||||
cli::{CliCommandHandler, Command},
|
||||
models::sonarr_models::DeleteSeriesParams,
|
||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
||||
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
use super::SonarrCommand;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
cli::{
|
||||
sonarr::{delete_command_handler::SonarrDeleteCommand, SonarrCommand},
|
||||
Command,
|
||||
},
|
||||
Cli,
|
||||
cli::{
|
||||
Command,
|
||||
sonarr::{SonarrCommand, delete_command_handler::SonarrDeleteCommand},
|
||||
},
|
||||
};
|
||||
use clap::{error::ErrorKind, CommandFactory, Parser};
|
||||
use clap::{CommandFactory, Parser, error::ErrorKind};
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
@@ -284,14 +284,14 @@ mod tests {
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{
|
||||
sonarr::delete_command_handler::{SonarrDeleteCommand, SonarrDeleteCommandHandler},
|
||||
CliCommandHandler,
|
||||
sonarr::delete_command_handler::{SonarrDeleteCommand, SonarrDeleteCommandHandler},
|
||||
},
|
||||
models::{
|
||||
sonarr_models::{DeleteSeriesParams, SonarrSerdeable},
|
||||
Serdeable,
|
||||
sonarr_models::{DeleteSeriesParams, SonarrSerdeable},
|
||||
},
|
||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
||||
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -8,7 +8,7 @@ use crate::{
|
||||
app::App,
|
||||
cli::{CliCommandHandler, Command},
|
||||
models::sonarr_models::SonarrReleaseDownloadBody,
|
||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
||||
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
use super::SonarrCommand;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
cli::{
|
||||
sonarr::{download_command_handler::SonarrDownloadCommand, SonarrCommand},
|
||||
Command,
|
||||
},
|
||||
Cli,
|
||||
cli::{
|
||||
Command,
|
||||
sonarr::{SonarrCommand, download_command_handler::SonarrDownloadCommand},
|
||||
},
|
||||
};
|
||||
use clap::CommandFactory;
|
||||
use pretty_assertions::assert_eq;
|
||||
@@ -303,14 +303,14 @@ mod tests {
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{
|
||||
sonarr::download_command_handler::{SonarrDownloadCommand, SonarrDownloadCommandHandler},
|
||||
CliCommandHandler,
|
||||
sonarr::download_command_handler::{SonarrDownloadCommand, SonarrDownloadCommandHandler},
|
||||
},
|
||||
models::{
|
||||
sonarr_models::{SonarrReleaseDownloadBody, SonarrSerdeable},
|
||||
Serdeable,
|
||||
sonarr_models::{SonarrReleaseDownloadBody, SonarrSerdeable},
|
||||
},
|
||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
||||
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -6,13 +6,13 @@ use tokio::sync::Mutex;
|
||||
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{mutex_flags_or_option, CliCommandHandler, Command},
|
||||
cli::{CliCommandHandler, Command, mutex_flags_or_option},
|
||||
models::{
|
||||
Serdeable,
|
||||
servarr_models::EditIndexerParams,
|
||||
sonarr_models::{EditSeriesParams, IndexerSettings, SeriesType, SonarrSerdeable},
|
||||
Serdeable,
|
||||
},
|
||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
||||
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
use super::SonarrCommand;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::cli::{
|
||||
sonarr::{edit_command_handler::SonarrEditCommand, SonarrCommand},
|
||||
Command,
|
||||
sonarr::{SonarrCommand, edit_command_handler::SonarrEditCommand},
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -20,10 +20,10 @@ mod tests {
|
||||
}
|
||||
|
||||
mod cli {
|
||||
use crate::{models::sonarr_models::SeriesType, Cli};
|
||||
use crate::{Cli, models::sonarr_models::SeriesType};
|
||||
|
||||
use super::*;
|
||||
use clap::{error::ErrorKind, CommandFactory, Parser};
|
||||
use clap::{CommandFactory, Parser, error::ErrorKind};
|
||||
use pretty_assertions::assert_eq;
|
||||
use rstest::rstest;
|
||||
|
||||
@@ -609,15 +609,15 @@ mod tests {
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{
|
||||
sonarr::edit_command_handler::{SonarrEditCommand, SonarrEditCommandHandler},
|
||||
CliCommandHandler,
|
||||
sonarr::edit_command_handler::{SonarrEditCommand, SonarrEditCommandHandler},
|
||||
},
|
||||
models::{
|
||||
Serdeable,
|
||||
servarr_models::EditIndexerParams,
|
||||
sonarr_models::{EditSeriesParams, IndexerSettings, SeriesType, SonarrSerdeable},
|
||||
Serdeable,
|
||||
},
|
||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
||||
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -7,7 +7,7 @@ use tokio::sync::Mutex;
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{CliCommandHandler, Command},
|
||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
||||
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
use super::SonarrCommand;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::cli::{
|
||||
sonarr::{get_command_handler::SonarrGetCommand, SonarrCommand},
|
||||
Command,
|
||||
};
|
||||
use crate::Cli;
|
||||
use crate::cli::{
|
||||
Command,
|
||||
sonarr::{SonarrCommand, get_command_handler::SonarrGetCommand},
|
||||
};
|
||||
use clap::CommandFactory;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
@@ -118,11 +118,11 @@ mod tests {
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{
|
||||
sonarr::get_command_handler::{SonarrGetCommand, SonarrGetCommandHandler},
|
||||
CliCommandHandler,
|
||||
sonarr::get_command_handler::{SonarrGetCommand, SonarrGetCommandHandler},
|
||||
},
|
||||
models::{sonarr_models::SonarrSerdeable, Serdeable},
|
||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
||||
models::{Serdeable, sonarr_models::SonarrSerdeable},
|
||||
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -7,7 +7,7 @@ use tokio::sync::Mutex;
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{CliCommandHandler, Command},
|
||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
||||
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
use super::SonarrCommand;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::cli::{
|
||||
sonarr::{list_command_handler::SonarrListCommand, SonarrCommand},
|
||||
Command,
|
||||
};
|
||||
use crate::Cli;
|
||||
use crate::cli::{
|
||||
Command,
|
||||
sonarr::{SonarrCommand, list_command_handler::SonarrListCommand},
|
||||
};
|
||||
use clap::CommandFactory;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
@@ -19,7 +19,7 @@ mod tests {
|
||||
|
||||
mod cli {
|
||||
use super::*;
|
||||
use clap::{error::ErrorKind, Parser};
|
||||
use clap::{Parser, error::ErrorKind};
|
||||
use pretty_assertions::assert_eq;
|
||||
use rstest::rstest;
|
||||
|
||||
@@ -296,10 +296,10 @@ mod tests {
|
||||
use serde_json::json;
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use crate::cli::sonarr::list_command_handler::{SonarrListCommand, SonarrListCommandHandler};
|
||||
use crate::cli::CliCommandHandler;
|
||||
use crate::models::sonarr_models::SonarrSerdeable;
|
||||
use crate::cli::sonarr::list_command_handler::{SonarrListCommand, SonarrListCommandHandler};
|
||||
use crate::models::Serdeable;
|
||||
use crate::models::sonarr_models::SonarrSerdeable;
|
||||
use crate::network::sonarr_network::SonarrEvent;
|
||||
use crate::{
|
||||
app::App,
|
||||
|
||||
@@ -7,7 +7,7 @@ use tokio::sync::Mutex;
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{CliCommandHandler, Command},
|
||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
||||
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
use super::SonarrCommand;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::cli::{
|
||||
sonarr::{manual_search_command_handler::SonarrManualSearchCommand, SonarrCommand},
|
||||
Command,
|
||||
};
|
||||
use crate::Cli;
|
||||
use crate::cli::{
|
||||
Command,
|
||||
sonarr::{SonarrCommand, manual_search_command_handler::SonarrManualSearchCommand},
|
||||
};
|
||||
use clap::CommandFactory;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
@@ -114,13 +114,13 @@ mod tests {
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{
|
||||
CliCommandHandler,
|
||||
sonarr::manual_search_command_handler::{
|
||||
SonarrManualSearchCommand, SonarrManualSearchCommandHandler,
|
||||
},
|
||||
CliCommandHandler,
|
||||
},
|
||||
models::{sonarr_models::SonarrSerdeable, Serdeable},
|
||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
||||
models::{Serdeable, sonarr_models::SonarrSerdeable},
|
||||
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
@@ -18,7 +18,7 @@ use trigger_automatic_search_command_handler::{
|
||||
use crate::{
|
||||
app::App,
|
||||
models::sonarr_models::SonarrTaskName,
|
||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
||||
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
use super::{CliCommandHandler, Command};
|
||||
|
||||
@@ -6,7 +6,7 @@ use tokio::sync::Mutex;
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{CliCommandHandler, Command},
|
||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
||||
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
use super::SonarrCommand;
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
mod tests {
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
use crate::cli::{
|
||||
sonarr::{refresh_command_handler::SonarrRefreshCommand, SonarrCommand},
|
||||
Command,
|
||||
};
|
||||
use crate::Cli;
|
||||
use crate::cli::{
|
||||
Command,
|
||||
sonarr::{SonarrCommand, refresh_command_handler::SonarrRefreshCommand},
|
||||
};
|
||||
use clap::CommandFactory;
|
||||
|
||||
#[test]
|
||||
@@ -20,7 +20,7 @@ mod tests {
|
||||
|
||||
mod cli {
|
||||
use super::*;
|
||||
use clap::{error::ErrorKind, Parser};
|
||||
use clap::{Parser, error::ErrorKind};
|
||||
use pretty_assertions::assert_eq;
|
||||
use rstest::rstest;
|
||||
|
||||
@@ -77,11 +77,11 @@ mod tests {
|
||||
|
||||
use crate::{app::App, cli::sonarr::refresh_command_handler::SonarrRefreshCommandHandler};
|
||||
use crate::{
|
||||
cli::{sonarr::refresh_command_handler::SonarrRefreshCommand, CliCommandHandler},
|
||||
cli::{CliCommandHandler, sonarr::refresh_command_handler::SonarrRefreshCommand},
|
||||
network::sonarr_network::SonarrEvent,
|
||||
};
|
||||
use crate::{
|
||||
models::{sonarr_models::SonarrSerdeable, Serdeable},
|
||||
models::{Serdeable, sonarr_models::SonarrSerdeable},
|
||||
network::{MockNetworkTrait, NetworkEvent},
|
||||
};
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::cli::{
|
||||
sonarr::{list_command_handler::SonarrListCommand, SonarrCommand},
|
||||
Command,
|
||||
};
|
||||
use crate::Cli;
|
||||
use crate::cli::{
|
||||
Command,
|
||||
sonarr::{SonarrCommand, list_command_handler::SonarrListCommand},
|
||||
};
|
||||
use clap::CommandFactory;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
@@ -253,25 +253,25 @@ mod tests {
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{
|
||||
CliCommandHandler,
|
||||
sonarr::{
|
||||
add_command_handler::SonarrAddCommand, delete_command_handler::SonarrDeleteCommand,
|
||||
SonarrCliHandler, SonarrCommand, add_command_handler::SonarrAddCommand,
|
||||
delete_command_handler::SonarrDeleteCommand,
|
||||
download_command_handler::SonarrDownloadCommand, edit_command_handler::SonarrEditCommand,
|
||||
get_command_handler::SonarrGetCommand, list_command_handler::SonarrListCommand,
|
||||
manual_search_command_handler::SonarrManualSearchCommand,
|
||||
refresh_command_handler::SonarrRefreshCommand,
|
||||
trigger_automatic_search_command_handler::SonarrTriggerAutomaticSearchCommand,
|
||||
SonarrCliHandler, SonarrCommand,
|
||||
},
|
||||
CliCommandHandler,
|
||||
},
|
||||
models::{
|
||||
Serdeable,
|
||||
sonarr_models::{
|
||||
BlocklistItem, BlocklistResponse, IndexerSettings, Series, SonarrReleaseDownloadBody,
|
||||
SonarrSerdeable, SonarrTaskName,
|
||||
},
|
||||
Serdeable,
|
||||
},
|
||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
||||
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
@@ -488,8 +488,8 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_sonarr_cli_handler_delegates_manual_search_commands_to_the_manual_search_command_handler(
|
||||
) {
|
||||
async fn test_sonarr_cli_handler_delegates_manual_search_commands_to_the_manual_search_command_handler()
|
||||
{
|
||||
let expected_episode_id = 1;
|
||||
let mut mock_network = MockNetworkTrait::new();
|
||||
mock_network
|
||||
@@ -516,8 +516,8 @@ mod tests {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_sonarr_cli_handler_delegates_trigger_automatic_search_commands_to_the_trigger_automatic_search_command_handler(
|
||||
) {
|
||||
async fn test_sonarr_cli_handler_delegates_trigger_automatic_search_commands_to_the_trigger_automatic_search_command_handler()
|
||||
{
|
||||
let expected_episode_id = 1;
|
||||
let mut mock_network = MockNetworkTrait::new();
|
||||
mock_network
|
||||
|
||||
@@ -7,7 +7,7 @@ use tokio::sync::Mutex;
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{CliCommandHandler, Command},
|
||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
||||
network::{NetworkTrait, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
use super::SonarrCommand;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::cli::{
|
||||
sonarr::{
|
||||
trigger_automatic_search_command_handler::SonarrTriggerAutomaticSearchCommand, SonarrCommand,
|
||||
},
|
||||
Command,
|
||||
};
|
||||
use crate::Cli;
|
||||
use crate::cli::{
|
||||
Command,
|
||||
sonarr::{
|
||||
SonarrCommand, trigger_automatic_search_command_handler::SonarrTriggerAutomaticSearchCommand,
|
||||
},
|
||||
};
|
||||
use clap::CommandFactory;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
@@ -150,13 +150,13 @@ mod tests {
|
||||
use crate::{
|
||||
app::App,
|
||||
cli::{
|
||||
CliCommandHandler,
|
||||
sonarr::trigger_automatic_search_command_handler::{
|
||||
SonarrTriggerAutomaticSearchCommand, SonarrTriggerAutomaticSearchCommandHandler,
|
||||
},
|
||||
CliCommandHandler,
|
||||
},
|
||||
models::{sonarr_models::SonarrSerdeable, Serdeable},
|
||||
network::{sonarr_network::SonarrEvent, MockNetworkTrait, NetworkEvent},
|
||||
models::{Serdeable, sonarr_models::SonarrSerdeable},
|
||||
network::{MockNetworkTrait, NetworkEvent, sonarr_network::SonarrEvent},
|
||||
};
|
||||
|
||||
#[tokio::test]
|
||||
|
||||
Reference in New Issue
Block a user