test: give the tree-local IndexerSettings fixtures distinct field values
Sonarr and Lidarr each keep their own copy of the shared fixture, both with minimum_age and retention set to 1, so transposing those two fields stayed invisible in either tree. Radarr built its fixture from IndexerSettings::default(), leaving availability_delay, maximum_size, minimum_age and retention all 0: four mutually transposable fields, none of which could distinguish a threaded value from a hardcoded 0. The no-op guard test seeded IndexerSettings::default() as its sentinel, which cannot show whether the guard held or the field was simply never written. It now seeds a distinct stale_indexer_settings(), mirroring the Readarr convention. Verified by transposing minimum_age and retention in the Lidarr indexer settings UI, now caught by its snapshot, and by inverting the Radarr no-op guard, now caught by both GetAllIndexerSettings tests.
This commit is contained in:
6 files changed
+54
-35
No files matched your search
@@ -274,9 +274,9 @@ pub(in crate::handlers::sonarr_handlers) mod utils {
|
|||||||
|
|
||||||
pub fn indexer_settings() -> IndexerSettings {
|
pub fn indexer_settings() -> IndexerSettings {
|
||||||
IndexerSettings {
|
IndexerSettings {
|
||||||
id: 1,
|
id: 7,
|
||||||
minimum_age: 1,
|
minimum_age: 13,
|
||||||
retention: 1,
|
retention: 21,
|
||||||
maximum_size: 12345,
|
maximum_size: 12345,
|
||||||
rss_sync_interval: 60,
|
rss_sync_interval: 60,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,10 +44,10 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_handle_edit_all_indexer_settings_event() {
|
async fn test_handle_edit_all_indexer_settings_event() {
|
||||||
let indexer_settings_json = json!({
|
let indexer_settings_json = json!({
|
||||||
"id": 1,
|
"id": 5,
|
||||||
"minimumAge": 1,
|
"minimumAge": 11,
|
||||||
"maximumSize": 12345,
|
"maximumSize": 12345,
|
||||||
"retention": 1,
|
"retention": 29,
|
||||||
"rssSyncInterval": 60
|
"rssSyncInterval": 60
|
||||||
});
|
});
|
||||||
let (mock, app, _server) = MockServarrApi::put()
|
let (mock, app, _server) = MockServarrApi::put()
|
||||||
|
|||||||
@@ -337,9 +337,9 @@ pub mod test_utils {
|
|||||||
|
|
||||||
pub fn indexer_settings() -> IndexerSettings {
|
pub fn indexer_settings() -> IndexerSettings {
|
||||||
IndexerSettings {
|
IndexerSettings {
|
||||||
id: 1,
|
id: 5,
|
||||||
minimum_age: 1,
|
minimum_age: 11,
|
||||||
retention: 1,
|
retention: 29,
|
||||||
maximum_size: 12345,
|
maximum_size: 12345,
|
||||||
rss_sync_interval: 60,
|
rss_sync_interval: 60,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ mod tests {
|
|||||||
use crate::network::network_tests::test_utils::{MockServarrApi, test_network};
|
use crate::network::network_tests::test_utils::{MockServarrApi, test_network};
|
||||||
use crate::network::radarr_network::RadarrEvent;
|
use crate::network::radarr_network::RadarrEvent;
|
||||||
use crate::network::radarr_network::radarr_network_test_utils::test_utils::{
|
use crate::network::radarr_network::radarr_network_test_utils::test_utils::{
|
||||||
indexer, indexer_settings,
|
indexer, indexer_settings, stale_indexer_settings,
|
||||||
};
|
};
|
||||||
use bimap::BiMap;
|
use bimap::BiMap;
|
||||||
use mockito::Matcher;
|
use mockito::Matcher;
|
||||||
@@ -36,15 +36,15 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_handle_edit_all_radarr_indexer_settings_event() {
|
async fn test_handle_edit_all_radarr_indexer_settings_event() {
|
||||||
let indexer_settings_json = json!({
|
let indexer_settings_json = json!({
|
||||||
"minimumAge": 0,
|
"minimumAge": 27,
|
||||||
"maximumSize": 0,
|
"maximumSize": 18400,
|
||||||
"retention": 0,
|
"retention": 44,
|
||||||
"rssSyncInterval": 60,
|
"rssSyncInterval": 60,
|
||||||
"preferIndexerFlags": false,
|
"preferIndexerFlags": false,
|
||||||
"availabilityDelay": 0,
|
"availabilityDelay": 19,
|
||||||
"allowHardcodedSubs": true,
|
"allowHardcodedSubs": true,
|
||||||
"whitelistedHardcodedSubs": "",
|
"whitelistedHardcodedSubs": "eng",
|
||||||
"id": 1
|
"id": 3
|
||||||
});
|
});
|
||||||
let (async_server, app, _server) = MockServarrApi::put()
|
let (async_server, app, _server) = MockServarrApi::put()
|
||||||
.with_request_body(indexer_settings_json)
|
.with_request_body(indexer_settings_json)
|
||||||
@@ -641,15 +641,15 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_handle_get_all_indexer_settings_event() {
|
async fn test_handle_get_all_indexer_settings_event() {
|
||||||
let indexer_settings_response_json = json!({
|
let indexer_settings_response_json = json!({
|
||||||
"minimumAge": 0,
|
"minimumAge": 27,
|
||||||
"maximumSize": 0,
|
"maximumSize": 18400,
|
||||||
"retention": 0,
|
"retention": 44,
|
||||||
"rssSyncInterval": 60,
|
"rssSyncInterval": 60,
|
||||||
"preferIndexerFlags": false,
|
"preferIndexerFlags": false,
|
||||||
"availabilityDelay": 0,
|
"availabilityDelay": 19,
|
||||||
"allowHardcodedSubs": true,
|
"allowHardcodedSubs": true,
|
||||||
"whitelistedHardcodedSubs": "",
|
"whitelistedHardcodedSubs": "eng",
|
||||||
"id": 1
|
"id": 3
|
||||||
});
|
});
|
||||||
let response: IndexerSettings =
|
let response: IndexerSettings =
|
||||||
serde_json::from_value(indexer_settings_response_json.clone()).unwrap();
|
serde_json::from_value(indexer_settings_response_json.clone()).unwrap();
|
||||||
@@ -677,21 +677,21 @@ mod tests {
|
|||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_handle_get_all_indexer_settings_event_no_op_if_already_present() {
|
async fn test_handle_get_all_indexer_settings_event_no_op_if_already_present() {
|
||||||
let indexer_settings_response_json = json!({
|
let indexer_settings_response_json = json!({
|
||||||
"minimumAge": 0,
|
"minimumAge": 27,
|
||||||
"maximumSize": 0,
|
"maximumSize": 18400,
|
||||||
"retention": 0,
|
"retention": 44,
|
||||||
"rssSyncInterval": 60,
|
"rssSyncInterval": 60,
|
||||||
"preferIndexerFlags": false,
|
"preferIndexerFlags": false,
|
||||||
"availabilityDelay": 0,
|
"availabilityDelay": 19,
|
||||||
"allowHardcodedSubs": true,
|
"allowHardcodedSubs": true,
|
||||||
"whitelistedHardcodedSubs": "",
|
"whitelistedHardcodedSubs": "eng",
|
||||||
"id": 1
|
"id": 3
|
||||||
});
|
});
|
||||||
let (async_server, app, _server) = MockServarrApi::get()
|
let (async_server, app, _server) = MockServarrApi::get()
|
||||||
.returns(indexer_settings_response_json)
|
.returns(indexer_settings_response_json)
|
||||||
.build_for(RadarrEvent::GetAllIndexerSettings)
|
.build_for(RadarrEvent::GetAllIndexerSettings)
|
||||||
.await;
|
.await;
|
||||||
app.lock().await.data.radarr_data.indexer_settings = Some(IndexerSettings::default());
|
app.lock().await.data.radarr_data.indexer_settings = Some(stale_indexer_settings());
|
||||||
let mut network = test_network(&app);
|
let mut network = test_network(&app);
|
||||||
|
|
||||||
assert!(
|
assert!(
|
||||||
@@ -704,7 +704,7 @@ mod tests {
|
|||||||
async_server.assert_async().await;
|
async_server.assert_async().await;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
app.lock().await.data.radarr_data.indexer_settings,
|
app.lock().await.data.radarr_data.indexer_settings,
|
||||||
Some(IndexerSettings::default())
|
Some(stale_indexer_settings())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -421,10 +421,29 @@ pub mod test_utils {
|
|||||||
|
|
||||||
pub fn indexer_settings() -> IndexerSettings {
|
pub fn indexer_settings() -> IndexerSettings {
|
||||||
IndexerSettings {
|
IndexerSettings {
|
||||||
rss_sync_interval: 60,
|
|
||||||
allow_hardcoded_subs: true,
|
allow_hardcoded_subs: true,
|
||||||
id: 1,
|
availability_delay: 19,
|
||||||
..IndexerSettings::default()
|
id: 3,
|
||||||
|
maximum_size: 18400,
|
||||||
|
minimum_age: 27,
|
||||||
|
prefer_indexer_flags: false,
|
||||||
|
retention: 44,
|
||||||
|
rss_sync_interval: 60,
|
||||||
|
whitelisted_hardcoded_subs: "eng".into(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn stale_indexer_settings() -> IndexerSettings {
|
||||||
|
IndexerSettings {
|
||||||
|
allow_hardcoded_subs: false,
|
||||||
|
availability_delay: 31,
|
||||||
|
id: 8,
|
||||||
|
maximum_size: 22750,
|
||||||
|
minimum_age: 52,
|
||||||
|
prefer_indexer_flags: true,
|
||||||
|
retention: 66,
|
||||||
|
rss_sync_interval: 90,
|
||||||
|
whitelisted_hardcoded_subs: "deu".into(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -21,10 +21,10 @@ expression: output
|
|||||||
│ │
|
│ │
|
||||||
│ │
|
│ │
|
||||||
│ ╭────────────────────────────────╮ │
|
│ ╭────────────────────────────────╮ │
|
||||||
│ Minimum Age (minutes) ▴▾: │1 │ │
|
│ Minimum Age (minutes) ▴▾: │11 │ │
|
||||||
│ ╰────────────────────────────────╯ │
|
│ ╰────────────────────────────────╯ │
|
||||||
│ ╭────────────────────────────────╮ │
|
│ ╭────────────────────────────────╮ │
|
||||||
│ Retention (days) ▴▾: │1 │ │
|
│ Retention (days) ▴▾: │29 │ │
|
||||||
│ ╰────────────────────────────────╯ │
|
│ ╰────────────────────────────────╯ │
|
||||||
│ ╭────────────────────────────────╮ │
|
│ ╭────────────────────────────────╮ │
|
||||||
│ Maximum Size (MB) ▴▾: │12345 │ │
|
│ Maximum Size (MB) ▴▾: │12345 │ │
|
||||||
|
|||||||
Reference in new issue
Block a user