Fixed rustfmt issues
This commit is contained in:
@@ -20,7 +20,7 @@ mod add_command_handler_tests;
|
|||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
|
#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
|
||||||
pub enum RadarrAddCommand {
|
pub enum RadarrAddCommand {
|
||||||
#[command(about = "Add a new movie to your Radarr library")]
|
#[command(about = "Add a new movie to your Radarr library")]
|
||||||
Movie {
|
Movie {
|
||||||
#[arg(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
@@ -50,22 +50,22 @@ pub enum RadarrAddCommand {
|
|||||||
#[arg(long, help = "Should Radarr monitor this film")]
|
#[arg(long, help = "Should Radarr monitor this film")]
|
||||||
disable_monitoring: bool,
|
disable_monitoring: bool,
|
||||||
#[arg(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
help = "Tag IDs to tag the film with",
|
help = "Tag IDs to tag the film with",
|
||||||
value_parser,
|
value_parser,
|
||||||
action = ArgAction::Append
|
action = ArgAction::Append
|
||||||
)]
|
)]
|
||||||
tag: Vec<i64>,
|
tag: Vec<i64>,
|
||||||
#[arg(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
help = "What Radarr should monitor",
|
help = "What Radarr should monitor",
|
||||||
value_enum,
|
value_enum,
|
||||||
default_value_t = Monitor::default()
|
default_value_t = Monitor::default()
|
||||||
)]
|
)]
|
||||||
monitor: Monitor,
|
monitor: Monitor,
|
||||||
#[arg(
|
#[arg(
|
||||||
long,
|
long,
|
||||||
help = "Tell Radarr to not start a search for this film once it's added to your library",
|
help = "Tell Radarr to not start a search for this film once it's added to your library"
|
||||||
)]
|
)]
|
||||||
no_search_for_movie: bool,
|
no_search_for_movie: bool,
|
||||||
},
|
},
|
||||||
@@ -77,14 +77,14 @@ pub enum RadarrAddCommand {
|
|||||||
#[command(about = "Add new tag")]
|
#[command(about = "Add new tag")]
|
||||||
Tag {
|
Tag {
|
||||||
#[arg(long, help = "The name of the tag to be added", required = true)]
|
#[arg(long, help = "The name of the tag to be added", required = true)]
|
||||||
name: String
|
name: String,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<RadarrAddCommand> for Command {
|
impl From<RadarrAddCommand> for Command {
|
||||||
fn from(value: RadarrAddCommand) -> Self {
|
fn from(value: RadarrAddCommand) -> Self {
|
||||||
Command::Radarr(RadarrCommand::Add(value))
|
Command::Radarr(RadarrCommand::Add(value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(super) struct RadarrAddCommandHandler<'a, 'b> {
|
pub(super) struct RadarrAddCommandHandler<'a, 'b> {
|
||||||
@@ -94,7 +94,11 @@ pub(super) struct RadarrAddCommandHandler<'a, 'b> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b> CliCommandHandler<'a, 'b, RadarrAddCommand> for RadarrAddCommandHandler<'a, 'b> {
|
impl<'a, 'b> CliCommandHandler<'a, 'b, RadarrAddCommand> for RadarrAddCommandHandler<'a, 'b> {
|
||||||
fn with(_app: &'a Arc<Mutex<App<'b>>>, command: RadarrAddCommand, network: &'a mut dyn NetworkTrait) -> Self {
|
fn with(
|
||||||
|
_app: &'a Arc<Mutex<App<'b>>>,
|
||||||
|
command: RadarrAddCommand,
|
||||||
|
network: &'a mut dyn NetworkTrait,
|
||||||
|
) -> Self {
|
||||||
RadarrAddCommandHandler {
|
RadarrAddCommandHandler {
|
||||||
_app,
|
_app,
|
||||||
command,
|
command,
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ mod tests {
|
|||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, MOVIE_DETAILS_BLOCKS};
|
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, MOVIE_DETAILS_BLOCKS};
|
||||||
use crate::ui::radarr_ui::library::movie_details_ui::{decorate_peer_style, MovieDetailsUi, style_from_download_status};
|
use crate::ui::radarr_ui::library::movie_details_ui::{
|
||||||
use crate::ui::DrawUi;
|
decorate_peer_style, style_from_download_status, MovieDetailsUi,
|
||||||
|
};
|
||||||
use crate::ui::styles::ManagarrStyle;
|
use crate::ui::styles::ManagarrStyle;
|
||||||
|
use crate::ui::DrawUi;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_movie_details_ui_accepts() {
|
fn test_movie_details_ui_accepts() {
|
||||||
@@ -21,7 +23,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
#[case("Downloading", true, "", Style::new().downloading())]
|
#[case("Downloading", true, "", Style::new().downloading())]
|
||||||
#[case("Downloaded", true, "", Style::new().downloaded())]
|
#[case("Downloaded", true, "", Style::new().downloaded())]
|
||||||
@@ -36,9 +38,12 @@ mod tests {
|
|||||||
#[case] movie_status: &str,
|
#[case] movie_status: &str,
|
||||||
#[case] expected_style: Style,
|
#[case] expected_style: Style,
|
||||||
) {
|
) {
|
||||||
assert_eq!(style_from_download_status(download_status, is_monitored, movie_status.to_owned()), expected_style);
|
assert_eq!(
|
||||||
|
style_from_download_status(download_status, is_monitored, movie_status.to_owned()),
|
||||||
|
expected_style
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
#[case(0, 0, PeerStyle::Failure)]
|
#[case(0, 0, PeerStyle::Failure)]
|
||||||
#[case(1, 2, PeerStyle::Warning)]
|
#[case(1, 2, PeerStyle::Warning)]
|
||||||
@@ -50,12 +55,21 @@ mod tests {
|
|||||||
) {
|
) {
|
||||||
let text = Text::from("test");
|
let text = Text::from("test");
|
||||||
match expected_style {
|
match expected_style {
|
||||||
PeerStyle::Failure => assert_eq!(decorate_peer_style(seeders, leechers, text.clone()), text.failure()),
|
PeerStyle::Failure => assert_eq!(
|
||||||
PeerStyle::Warning => assert_eq!(decorate_peer_style(seeders, leechers, text.clone()), text.warning()),
|
decorate_peer_style(seeders, leechers, text.clone()),
|
||||||
PeerStyle::Success => assert_eq!(decorate_peer_style(seeders, leechers, text.clone()), text.success()),
|
text.failure()
|
||||||
|
),
|
||||||
|
PeerStyle::Warning => assert_eq!(
|
||||||
|
decorate_peer_style(seeders, leechers, text.clone()),
|
||||||
|
text.warning()
|
||||||
|
),
|
||||||
|
PeerStyle::Success => assert_eq!(
|
||||||
|
decorate_peer_style(seeders, leechers, text.clone()),
|
||||||
|
text.success()
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum PeerStyle {
|
enum PeerStyle {
|
||||||
Failure,
|
Failure,
|
||||||
Warning,
|
Warning,
|
||||||
|
|||||||
@@ -224,7 +224,7 @@ fn decorate_with_row_style<'a>(
|
|||||||
if !movie.monitored {
|
if !movie.monitored {
|
||||||
return row.unmonitored_missing();
|
return row.unmonitored_missing();
|
||||||
}
|
}
|
||||||
|
|
||||||
if movie.status != "released" {
|
if movie.status != "released" {
|
||||||
return row.unreleased();
|
return row.unreleased();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use crate::models::radarr_models::{DownloadRecord, Movie};
|
||||||
use pretty_assertions::assert_eq;
|
use pretty_assertions::assert_eq;
|
||||||
use ratatui::widgets::{Cell, Row};
|
use ratatui::widgets::{Cell, Row};
|
||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
use strum::IntoEnumIterator;
|
use strum::IntoEnumIterator;
|
||||||
use crate::models::radarr_models::{DownloadRecord, Movie};
|
|
||||||
|
|
||||||
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
use crate::models::servarr_data::radarr::radarr_data::ActiveRadarrBlock;
|
||||||
use crate::ui::radarr_ui::{decorate_with_row_style, RadarrUi};
|
use crate::ui::radarr_ui::{decorate_with_row_style, RadarrUi};
|
||||||
use crate::ui::DrawUi;
|
|
||||||
use crate::ui::styles::ManagarrStyle;
|
use crate::ui::styles::ManagarrStyle;
|
||||||
|
use crate::ui::DrawUi;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_radarr_ui_accepts() {
|
fn test_radarr_ui_accepts() {
|
||||||
@@ -17,7 +17,7 @@ mod tests {
|
|||||||
assert!(RadarrUi::accepts(active_radarr_block.into()));
|
assert!(RadarrUi::accepts(active_radarr_block.into()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
#[case(false, Some("downloading"), false, "", RowStyle::Downloading)]
|
#[case(false, Some("downloading"), false, "", RowStyle::Downloading)]
|
||||||
#[case(false, Some("completed"), false, "", RowStyle::AwaitingImport)]
|
#[case(false, Some("completed"), false, "", RowStyle::AwaitingImport)]
|
||||||
@@ -50,9 +50,9 @@ mod tests {
|
|||||||
..Movie::default()
|
..Movie::default()
|
||||||
};
|
};
|
||||||
let row = Row::new(vec![Cell::from("test".to_owned())]);
|
let row = Row::new(vec![Cell::from("test".to_owned())]);
|
||||||
|
|
||||||
let style = decorate_with_row_style(&downloads_vec, &movie, row.clone());
|
let style = decorate_with_row_style(&downloads_vec, &movie, row.clone());
|
||||||
|
|
||||||
match expected_style {
|
match expected_style {
|
||||||
RowStyle::AwaitingImport => assert_eq!(style, row.awaiting_import()),
|
RowStyle::AwaitingImport => assert_eq!(style, row.awaiting_import()),
|
||||||
RowStyle::Downloaded => assert_eq!(style, row.downloaded()),
|
RowStyle::Downloaded => assert_eq!(style, row.downloaded()),
|
||||||
@@ -63,7 +63,7 @@ mod tests {
|
|||||||
RowStyle::Unreleased => assert_eq!(style, row.unreleased()),
|
RowStyle::Unreleased => assert_eq!(style, row.unreleased()),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
enum RowStyle {
|
enum RowStyle {
|
||||||
AwaitingImport,
|
AwaitingImport,
|
||||||
Downloaded,
|
Downloaded,
|
||||||
|
|||||||
Reference in New Issue
Block a user