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
@@ -44,10 +44,10 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn test_handle_edit_all_indexer_settings_event() {
|
||||
let indexer_settings_json = json!({
|
||||
"id": 1,
|
||||
"minimumAge": 1,
|
||||
"id": 5,
|
||||
"minimumAge": 11,
|
||||
"maximumSize": 12345,
|
||||
"retention": 1,
|
||||
"retention": 29,
|
||||
"rssSyncInterval": 60
|
||||
});
|
||||
let (mock, app, _server) = MockServarrApi::put()
|
||||
|
||||
@@ -337,9 +337,9 @@ pub mod test_utils {
|
||||
|
||||
pub fn indexer_settings() -> IndexerSettings {
|
||||
IndexerSettings {
|
||||
id: 1,
|
||||
minimum_age: 1,
|
||||
retention: 1,
|
||||
id: 5,
|
||||
minimum_age: 11,
|
||||
retention: 29,
|
||||
maximum_size: 12345,
|
||||
rss_sync_interval: 60,
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ mod tests {
|
||||
use crate::network::network_tests::test_utils::{MockServarrApi, test_network};
|
||||
use crate::network::radarr_network::RadarrEvent;
|
||||
use crate::network::radarr_network::radarr_network_test_utils::test_utils::{
|
||||
indexer, indexer_settings,
|
||||
indexer, indexer_settings, stale_indexer_settings,
|
||||
};
|
||||
use bimap::BiMap;
|
||||
use mockito::Matcher;
|
||||
@@ -36,15 +36,15 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn test_handle_edit_all_radarr_indexer_settings_event() {
|
||||
let indexer_settings_json = json!({
|
||||
"minimumAge": 0,
|
||||
"maximumSize": 0,
|
||||
"retention": 0,
|
||||
"minimumAge": 27,
|
||||
"maximumSize": 18400,
|
||||
"retention": 44,
|
||||
"rssSyncInterval": 60,
|
||||
"preferIndexerFlags": false,
|
||||
"availabilityDelay": 0,
|
||||
"availabilityDelay": 19,
|
||||
"allowHardcodedSubs": true,
|
||||
"whitelistedHardcodedSubs": "",
|
||||
"id": 1
|
||||
"whitelistedHardcodedSubs": "eng",
|
||||
"id": 3
|
||||
});
|
||||
let (async_server, app, _server) = MockServarrApi::put()
|
||||
.with_request_body(indexer_settings_json)
|
||||
@@ -641,15 +641,15 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn test_handle_get_all_indexer_settings_event() {
|
||||
let indexer_settings_response_json = json!({
|
||||
"minimumAge": 0,
|
||||
"maximumSize": 0,
|
||||
"retention": 0,
|
||||
"minimumAge": 27,
|
||||
"maximumSize": 18400,
|
||||
"retention": 44,
|
||||
"rssSyncInterval": 60,
|
||||
"preferIndexerFlags": false,
|
||||
"availabilityDelay": 0,
|
||||
"availabilityDelay": 19,
|
||||
"allowHardcodedSubs": true,
|
||||
"whitelistedHardcodedSubs": "",
|
||||
"id": 1
|
||||
"whitelistedHardcodedSubs": "eng",
|
||||
"id": 3
|
||||
});
|
||||
let response: IndexerSettings =
|
||||
serde_json::from_value(indexer_settings_response_json.clone()).unwrap();
|
||||
@@ -677,21 +677,21 @@ mod tests {
|
||||
#[tokio::test]
|
||||
async fn test_handle_get_all_indexer_settings_event_no_op_if_already_present() {
|
||||
let indexer_settings_response_json = json!({
|
||||
"minimumAge": 0,
|
||||
"maximumSize": 0,
|
||||
"retention": 0,
|
||||
"minimumAge": 27,
|
||||
"maximumSize": 18400,
|
||||
"retention": 44,
|
||||
"rssSyncInterval": 60,
|
||||
"preferIndexerFlags": false,
|
||||
"availabilityDelay": 0,
|
||||
"availabilityDelay": 19,
|
||||
"allowHardcodedSubs": true,
|
||||
"whitelistedHardcodedSubs": "",
|
||||
"id": 1
|
||||
"whitelistedHardcodedSubs": "eng",
|
||||
"id": 3
|
||||
});
|
||||
let (async_server, app, _server) = MockServarrApi::get()
|
||||
.returns(indexer_settings_response_json)
|
||||
.build_for(RadarrEvent::GetAllIndexerSettings)
|
||||
.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);
|
||||
|
||||
assert!(
|
||||
@@ -704,7 +704,7 @@ mod tests {
|
||||
async_server.assert_async().await;
|
||||
assert_eq!(
|
||||
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 {
|
||||
IndexerSettings {
|
||||
rss_sync_interval: 60,
|
||||
allow_hardcoded_subs: true,
|
||||
id: 1,
|
||||
..IndexerSettings::default()
|
||||
availability_delay: 19,
|
||||
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(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user