test(sonarr): give the download record and episode fixtures distinct ids

The shared download record held id and episode id both equal to 1, and
the shared episode held id and episode file id both equal to 1, so
reading the wrong one of those fields could not fail any test that uses
them. Move the download record to id 9 and the episode to id 11, keeping
the download record's episode id equal to the episode's id so the
downloading episode still matches, and move the episode file to id 7
together with the episode's episode file id so the season view still
finds its quality and size. Series id, season number, and episode number
stay at 1. The handler tree keeps its own copy of these fixtures; update
it identically, along with the JSON twins in the network tests and the
seven handler assertions that named the old ids. The two get episodes
tests that asserted the sorted table now spell out the sorted order,
since the fixture episode no longer sorts first by id.
This commit is contained in:
Dark-Alex-17 committed 2026-09-17 18:22:31 -06:00
1 parent 4f78a5940f
commit 040935178a
7 files changed
+28 -27

No files matched your search

@@ -140,7 +140,7 @@ mod tests {
#[case(
ActiveSonarrBlock::Downloads,
ActiveSonarrBlock::DeleteDownloadPrompt,
SonarrEvent::DeleteDownload(1)
SonarrEvent::DeleteDownload(9)
)]
#[case(
ActiveSonarrBlock::Downloads,
@@ -340,7 +340,7 @@ mod tests {
#[case(
ActiveSonarrBlock::Downloads,
ActiveSonarrBlock::DeleteDownloadPrompt,
SonarrEvent::DeleteDownload(1)
SonarrEvent::DeleteDownload(9)
)]
#[case(
ActiveSonarrBlock::Downloads,
@@ -431,7 +431,7 @@ mod tests {
)
.extract_download_id();
assert_eq!(download_id, 1);
assert_eq!(download_id, 9);
}
#[test]
@@ -207,7 +207,7 @@ mod tests {
#[rstest]
#[case(
ActiveSonarrBlock::AutomaticallySearchEpisodePrompt,
SonarrEvent::TriggerAutomaticEpisodeSearch(1)
SonarrEvent::TriggerAutomaticEpisodeSearch(11)
)]
fn test_episode_details_prompt_confirm_submit(
#[case] prompt_block: ActiveSonarrBlock,
@@ -646,7 +646,7 @@ mod tests {
assert_navigation_popped!(app, active_sonarr_block.into());
assert_some_eq_x!(
&app.data.sonarr_data.prompt_confirm_action,
&SonarrEvent::TriggerAutomaticEpisodeSearch(1)
&SonarrEvent::TriggerAutomaticEpisodeSearch(11)
);
}
@@ -787,7 +787,7 @@ mod tests {
)
.extract_episode_id();
assert_eq!(episode_id, 1);
assert_eq!(episode_id, 11);
}
#[test]
@@ -673,7 +673,7 @@ mod tests {
assert!(app.is_routing);
assert_some_eq_x!(
&app.data.sonarr_data.prompt_confirm_action,
&SonarrEvent::ToggleEpisodeMonitoring(1)
&SonarrEvent::ToggleEpisodeMonitoring(11)
);
}
@@ -1129,7 +1129,7 @@ mod tests {
)
.extract_episode_id();
assert_eq!(episode_id, 1);
assert_eq!(episode_id, 11);
}
#[test]
@@ -191,8 +191,8 @@ pub(in crate::handlers::sonarr_handlers) mod utils {
DownloadRecord {
title: "Test Download Title".to_owned(),
status: DownloadStatus::Downloading,
id: 1,
episode_id: Some(Number::from(1i64)),
id: 9,
episode_id: Some(Number::from(11i64)),
size: 3543348019f64,
sizeleft: 1771674009f64,
output_path: Some(HorizontallyScrollableText::from(
@@ -205,10 +205,10 @@ pub(in crate::handlers::sonarr_handlers) mod utils {
pub fn episode() -> Episode {
Episode {
id: 1,
id: 11,
series_id: 1,
tvdb_id: 1234,
episode_file_id: 1,
episode_file_id: 7,
season_number: 1,
episode_number: 1,
title: "Something cool".to_owned(),
@@ -224,7 +224,7 @@ pub(in crate::handlers::sonarr_handlers) mod utils {
pub fn episode_file() -> EpisodeFile {
EpisodeFile {
id: 1,
id: 7,
relative_path: "/season 1/episode 1.mkv".to_owned(),
path: "/nfs/tv/series/season 1/episode 1.mkv".to_owned(),
size: 3543348019,
@@ -41,8 +41,8 @@ mod tests {
"records": [{
"title": "Test Download Title",
"status": "downloading",
"id": 1,
"episodeId": 1,
"id": 9,
"episodeId": 11,
"size": 3543348019f64,
"sizeleft": 1771674009f64,
"outputPath": "/nfs/tv/Test show/season 1/",
@@ -69,7 +69,7 @@ mod tests {
..episode()
};
let expected_episodes = vec![episode_1.clone(), episode_2.clone(), episode_3.clone()];
let mut expected_sorted_episodes = vec![episode_1.clone(), episode_3.clone()];
let mut expected_sorted_episodes = vec![episode_3.clone(), episode_1.clone()];
let (mock, app, _server) = MockServarrApi::get()
.query("seriesId=1")
.returns(json!([episode_1, episode_2, episode_3]))
@@ -175,6 +175,7 @@ mod tests {
..episode()
};
let expected_episodes = vec![episode_1.clone(), episode_2.clone(), episode_3.clone()];
let expected_sorted_episodes = vec![episode_2.clone(), episode_3.clone(), episode_1.clone()];
let (mock, app, _server) = MockServarrApi::get()
.query("seriesId=1")
.returns(json!([episode_1, episode_2, episode_3]))
@@ -216,7 +217,7 @@ mod tests {
.unwrap()
.episodes
.items,
expected_episodes
expected_sorted_episodes
);
assert!(
app
@@ -294,10 +295,10 @@ mod tests {
"monitored": true
},
{
"id": 1,
"id": 11,
"seriesId": 1,
"tvdbId": 1234,
"episodeFileId": 1,
"episodeFileId": 7,
"seasonNumber": 1,
"episodeNumber": 1,
"title": "Something cool",
@@ -64,14 +64,14 @@ pub mod test_utils {
pub const EPISODE_JSON: &str = r#"{
"seriesId": 1,
"tvdbId": 1234,
"episodeFileId": 1,
"episodeFileId": 7,
"seasonNumber": 1,
"episodeNumber": 1,
"title": "Something cool",
"airDateUtc": "2024-02-10T07:28:45Z",
"overview": "Okay so this one time at band camp...",
"episodeFile": {
"id": 1,
"id": 7,
"relativePath": "/season 1/episode 1.mkv",
"path": "/nfs/tv/series/season 1/episode 1.mkv",
"size": 3543348019,
@@ -96,7 +96,7 @@ pub mod test_utils {
},
"hasFile": true,
"monitored": true,
"id": 1
"id": 11
}"#;
pub fn add_series_search_result() -> AddSeriesSearchResult {
@@ -139,8 +139,8 @@ pub mod test_utils {
DownloadRecord {
title: "Test Download Title".to_owned(),
status: DownloadStatus::Downloading,
id: 1,
episode_id: Some(Number::from(1i64)),
id: 9,
episode_id: Some(Number::from(11i64)),
size: 3543348019f64,
sizeleft: 1771674009f64,
output_path: Some(HorizontallyScrollableText::from(
@@ -159,10 +159,10 @@ pub mod test_utils {
pub fn episode() -> Episode {
Episode {
id: 1,
id: 11,
series_id: 1,
tvdb_id: 1234,
episode_file_id: 1,
episode_file_id: 7,
season_number: 1,
episode_number: 1,
title: "Something cool".to_owned(),
@@ -178,7 +178,7 @@ pub mod test_utils {
pub fn episode_file() -> EpisodeFile {
EpisodeFile {
id: 1,
id: 7,
relative_path: "/season 1/episode 1.mkv".to_owned(),
path: "/nfs/tv/series/season 1/episode 1.mkv".to_owned(),
size: 3543348019,