//! Tests for `report::serve` (split at the 500-line cap). use crate::report::ReportRow; use crate::report::quality::Medals; use crate::report::stale::ledger_differs; fn row(name: &str, up: Option) -> ReportRow { ReportRow { name: name.to_string(), title: name.to_string(), model: "m".to_string(), parent: "m".to_string(), quant: "nvfp4".to_string(), engine: "vllm".to_string(), image: "img".to_string(), nodes: None, tp: 1, deploy: "docker".to_string(), port: 30000, incomplete: false, up, up_cluster: None, runs: 0, fleet_up: false, fleet_since: None, medals: Medals::default(), stale: false, reports: Vec::new(), } } /// A `stop` that closed a ledger (or a `serve` that opened one) must force a /// full re-collect — that is how the panel learns a lane is gone. #[test] fn ledger_diff_detects_stopped_and_started_lanes() { use std::collections::HashSet; let rows = vec![row("a", Some(1000)), row("b", None), row("c", Some(2000))]; let led = HashSet::from(["a".to_string()]); assert!( ledger_differs(&rows, &led), "a closed run must force a re-collect" ); let led = HashSet::from(["a".to_string(), "c".to_string()]); assert!(!ledger_differs(&rows, &led), "ledger matches the rows"); let led = HashSet::from(["a".to_string(), "b".to_string(), "c".to_string()]); assert!( ledger_differs(&rows, &led), "a newly opened run must force a re-collect" ); }