Promote Route::Readarr from a unit stub to a tuple variant and wire Readarr through every layer, mirroring the Lidarr tree. Readarr appears as a fourth servarr tab and its library view renders the Authors table. Adds ReadarrData and its modals, the tick and context clue modules, the top-level ReadarrHandler, ReadarrUi with the Authors library view, and an empty ReadarrCommand behind ReadarrCliHandler. The default port is 8787. Promoting the route variant compiles cleanly without any of the arms that give it behaviour, so all six of those sites are wired explicitly here: App::on_tick, handlers::handle_events, handle_prompt_toggle, ServarrContextClueProvider, ui(), and verify_config_present_for_cli. Each was checked by removing the arm and confirming its covering assertion then fails. ReadarrEvent and ReadarrCommand are both declared empty. They gain variants alongside the network calls and CLI commands that use them, which keeps each later change to a single function. Adding the tab changes the rendered tab bar, so 13 existing snapshots regenerate. The only delta in each is that single tab bar line. This scaffold adds 24 dead_code warnings, all inside the Readarr tree and none outside it. They clear as the handlers, UI, network events, and CLI commands that consume these items land: block arrays awaiting their accepts implementations and BlockSelectionState seeding, modal and state fields awaiting their handlers, the CLI handler fields awaiting an inhabited command enum, and the top-level handler fields awaiting sub-handlers. The count must strictly decrease from here, so a later increase is a defect rather than transient noise. The 12 pre-existing collapsible_match warnings are unrelated and untouched.
113 lines
3.1 KiB
Rust
113 lines
3.1 KiB
Rust
#[cfg(test)]
|
|
mod tests {
|
|
use crate::app::App;
|
|
use crate::models::servarr_data::readarr::readarr_data::ActiveReadarrBlock;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[tokio::test]
|
|
async fn test_dispatch_by_readarr_block_resets_the_tick_count() {
|
|
let mut app = App {
|
|
tick_count: 2,
|
|
..App::test_default()
|
|
};
|
|
|
|
app
|
|
.dispatch_by_readarr_block(&ActiveReadarrBlock::Authors)
|
|
.await;
|
|
|
|
assert_eq!(app.tick_count, 0);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_dispatch_by_readarr_block_clears_the_pending_prompt_confirmation() {
|
|
let mut app = App::test_default();
|
|
app.data.readarr_data.prompt_confirm = true;
|
|
|
|
app
|
|
.dispatch_by_readarr_block(&ActiveReadarrBlock::Authors)
|
|
.await;
|
|
|
|
assert!(!app.data.readarr_data.prompt_confirm);
|
|
assert!(!app.should_refresh);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_check_for_readarr_prompt_action_no_prompt_confirm() {
|
|
let mut app = App::test_default();
|
|
app.data.readarr_data.prompt_confirm = false;
|
|
|
|
app.check_for_readarr_prompt_action().await;
|
|
|
|
assert!(!app.data.readarr_data.prompt_confirm);
|
|
assert!(!app.should_refresh);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_check_for_readarr_prompt_action_with_no_prompt_confirm_action() {
|
|
let mut app = App::test_default();
|
|
app.data.readarr_data.prompt_confirm = true;
|
|
|
|
app.check_for_readarr_prompt_action().await;
|
|
|
|
assert!(!app.data.readarr_data.prompt_confirm);
|
|
assert_none!(app.data.readarr_data.prompt_confirm_action);
|
|
assert!(!app.should_refresh);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_readarr_on_tick_first_render() {
|
|
let mut app = App::test_default();
|
|
app.data.readarr_data.prompt_confirm = true;
|
|
app.is_first_render = true;
|
|
|
|
app.readarr_on_tick(ActiveReadarrBlock::Downloads).await;
|
|
|
|
assert!(!app.data.readarr_data.prompt_confirm);
|
|
assert!(!app.is_first_render);
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_readarr_on_tick_routing() {
|
|
let mut app = App::test_default();
|
|
app.data.readarr_data.prompt_confirm = true;
|
|
app.is_routing = true;
|
|
app.should_refresh = true;
|
|
app.is_first_render = false;
|
|
app.tick_count = 1;
|
|
|
|
app.readarr_on_tick(ActiveReadarrBlock::Downloads).await;
|
|
|
|
assert!(!app.data.readarr_data.prompt_confirm);
|
|
assert!(!app.cancellation_token.is_cancelled());
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_readarr_on_tick_routing_while_long_request_is_running_should_cancel_request() {
|
|
let mut app = App::test_default();
|
|
app.data.readarr_data.prompt_confirm = true;
|
|
app.is_routing = true;
|
|
app.should_refresh = false;
|
|
app.is_first_render = false;
|
|
app.tick_count = 1;
|
|
|
|
app.readarr_on_tick(ActiveReadarrBlock::Downloads).await;
|
|
|
|
assert!(app.cancellation_token.is_cancelled());
|
|
}
|
|
|
|
#[tokio::test]
|
|
async fn test_readarr_on_tick_should_refresh() {
|
|
let mut app = App::test_default();
|
|
app.data.readarr_data.prompt_confirm = true;
|
|
app.should_refresh = true;
|
|
app.is_first_render = false;
|
|
app.tick_count = 1;
|
|
|
|
app.readarr_on_tick(ActiveReadarrBlock::Downloads).await;
|
|
|
|
assert!(app.should_refresh);
|
|
assert!(!app.data.readarr_data.prompt_confirm);
|
|
assert_eq!(app.tick_count, 0);
|
|
}
|
|
}
|