refactor: share one DownloadStatus enum across the servarr models
DownloadStatus was declared four times, byte for byte identically, in radarr_models, sonarr_models, lidarr_models, and readarr_models: the same variants, the same derive list, and the same serde, strum, and display_style attributes. Every servarr's queue endpoint reports the same status vocabulary, so there is nothing servarr specific about the type. Move it into servarr_models, preserving that file's alphabetical ordering (between DiskSpace and IndexerSettings), and drop the four copies. The DownloadRecord types keep their per-servarr shapes and now reference the shared enum. The two enum tests, test_download_status_display and test_download_status_to_display_str, were likewise duplicated in the four per-servarr model test files. Keep one copy of each in servarr_models_tests alongside the other shared enum display tests and delete the rest. The per-servarr DownloadRecord fallback deserialization tests stay where they are since they exercise each servarr's own record type. Behavior is unchanged. Every remaining edit is an import path update.
This commit is contained in:
31 files changed
+149
-335
No files matched your search
@@ -7,14 +7,14 @@ mod tests {
|
||||
|
||||
use crate::models::readarr_models::{
|
||||
AddAuthorSearchResult, BlocklistItem, BlocklistResponse, Book, BookFile, DownloadRecord,
|
||||
DownloadStatus, DownloadsResponse, Edition, MediaInfo, MonitorType, NewItemMonitorType,
|
||||
DownloadsResponse, Edition, MediaInfo, MonitorType, NewItemMonitorType,
|
||||
ReadarrHistoryEventType, ReadarrHistoryItem, ReadarrHistoryWrapper, ReadarrRelease,
|
||||
ReadarrTask, ReadarrTaskName,
|
||||
};
|
||||
use crate::models::servarr_models::{
|
||||
DiskSpace, HostConfig, Indexer, IndexerSettings, IndexerTestResult, Log, LogResponse,
|
||||
MetadataProfile, QualityProfile, QueueEvent, RootFolder, SecurityConfig, SystemStatus, Tag,
|
||||
Update,
|
||||
DiskSpace, DownloadStatus, HostConfig, Indexer, IndexerSettings, IndexerTestResult, Log,
|
||||
LogResponse, MetadataProfile, QualityProfile, QueueEvent, RootFolder, SecurityConfig,
|
||||
SystemStatus, Tag, Update,
|
||||
};
|
||||
use crate::models::{
|
||||
Serdeable,
|
||||
@@ -644,40 +644,6 @@ mod tests {
|
||||
assert_str_eq!(AuthorStatus::Deleted.to_display_str(), "Deleted");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_download_status_display() {
|
||||
assert_str_eq!(DownloadStatus::Unknown.to_string(), "unknown");
|
||||
assert_str_eq!(DownloadStatus::Queued.to_string(), "queued");
|
||||
assert_str_eq!(DownloadStatus::Paused.to_string(), "paused");
|
||||
assert_str_eq!(DownloadStatus::Downloading.to_string(), "downloading");
|
||||
assert_str_eq!(DownloadStatus::Completed.to_string(), "completed");
|
||||
assert_str_eq!(DownloadStatus::Failed.to_string(), "failed");
|
||||
assert_str_eq!(DownloadStatus::Warning.to_string(), "warning");
|
||||
assert_str_eq!(DownloadStatus::Delay.to_string(), "delay");
|
||||
assert_str_eq!(
|
||||
DownloadStatus::DownloadClientUnavailable.to_string(),
|
||||
"downloadClientUnavailable"
|
||||
);
|
||||
assert_str_eq!(DownloadStatus::Fallback.to_string(), "fallback");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_download_status_to_display_str() {
|
||||
assert_str_eq!(DownloadStatus::Unknown.to_display_str(), "Unknown");
|
||||
assert_str_eq!(DownloadStatus::Queued.to_display_str(), "Queued");
|
||||
assert_str_eq!(DownloadStatus::Paused.to_display_str(), "Paused");
|
||||
assert_str_eq!(DownloadStatus::Downloading.to_display_str(), "Downloading");
|
||||
assert_str_eq!(DownloadStatus::Completed.to_display_str(), "Completed");
|
||||
assert_str_eq!(DownloadStatus::Failed.to_display_str(), "Failed");
|
||||
assert_str_eq!(DownloadStatus::Warning.to_display_str(), "Warning");
|
||||
assert_str_eq!(DownloadStatus::Delay.to_display_str(), "Delay");
|
||||
assert_str_eq!(
|
||||
DownloadStatus::DownloadClientUnavailable.to_display_str(),
|
||||
"Download Client Unavailable"
|
||||
);
|
||||
assert_str_eq!(DownloadStatus::Fallback.to_display_str(), "Fallback");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_readarr_history_event_type_display() {
|
||||
assert_str_eq!(ReadarrHistoryEventType::Unknown.to_string(), "unknown");
|
||||
|
||||
Reference in new issue
Block a user