Partial implementation of Tasks and Logs and test refactor
This commit is contained in:
+32
-44
@@ -8,6 +8,10 @@ use strum_macros::{Display, EnumIter};
|
||||
|
||||
use crate::models::HorizontallyScrollableText;
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "radarr_models_tests.rs"]
|
||||
mod radarr_models_tests;
|
||||
|
||||
#[derive(Deserialize, Debug, Clone, Eq, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct DiskSpace {
|
||||
@@ -404,48 +408,32 @@ impl Monitor {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use pretty_assertions::assert_str_eq;
|
||||
|
||||
use crate::models::radarr_models::{MinimumAvailability, Monitor};
|
||||
|
||||
#[test]
|
||||
fn test_minimum_availability_display() {
|
||||
assert_str_eq!(MinimumAvailability::Tba.to_string(), "tba");
|
||||
assert_str_eq!(MinimumAvailability::Announced.to_string(), "announced");
|
||||
assert_str_eq!(MinimumAvailability::InCinemas.to_string(), "inCinemas");
|
||||
assert_str_eq!(MinimumAvailability::Released.to_string(), "released");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_minimum_availability_to_display_str() {
|
||||
assert_str_eq!(MinimumAvailability::Tba.to_display_str(), "TBA");
|
||||
assert_str_eq!(MinimumAvailability::Announced.to_display_str(), "Announced");
|
||||
assert_str_eq!(
|
||||
MinimumAvailability::InCinemas.to_display_str(),
|
||||
"In Cinemas"
|
||||
);
|
||||
assert_str_eq!(MinimumAvailability::Released.to_display_str(), "Released");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_monitor_display() {
|
||||
assert_str_eq!(Monitor::MovieOnly.to_string(), "movieOnly");
|
||||
assert_str_eq!(
|
||||
Monitor::MovieAndCollection.to_string(),
|
||||
"movieAndCollection"
|
||||
);
|
||||
assert_str_eq!(Monitor::None.to_string(), "none");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_monitor_to_display_str() {
|
||||
assert_str_eq!(Monitor::MovieOnly.to_display_str(), "Movie only");
|
||||
assert_str_eq!(
|
||||
Monitor::MovieAndCollection.to_display_str(),
|
||||
"Movie and Collection"
|
||||
);
|
||||
assert_str_eq!(Monitor::None.to_display_str(), "None");
|
||||
}
|
||||
#[derive(Default, Deserialize, Clone, Debug, Eq, PartialEq)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Log {
|
||||
pub time: DateTime<Utc>,
|
||||
pub exception: Option<String>,
|
||||
pub exception_type: Option<String>,
|
||||
pub level: Option<String>,
|
||||
pub logger: Option<String>,
|
||||
pub message: Option<String>,
|
||||
pub method: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Default, Deserialize, Debug, Eq, PartialEq)]
|
||||
pub struct LogResponse {
|
||||
pub records: Vec<Log>,
|
||||
}
|
||||
|
||||
#[derive(Derivative, Deserialize, Debug, Clone, PartialEq, Eq)]
|
||||
#[derivative(Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Task {
|
||||
pub name: String,
|
||||
pub task_name: String,
|
||||
#[derivative(Default(value = "Number::from(0)"))]
|
||||
pub interval: Number,
|
||||
pub last_execution: DateTime<Utc>,
|
||||
pub last_duration: String,
|
||||
pub next_execution: DateTime<Utc>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user