sources: Refreshed::is_clean decides the exit, where a test reaches it
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6a0ab4a7ab
commit
715ec58180
3 changed files with 16 additions and 1 deletions
|
|
@ -81,7 +81,7 @@ fn main() -> ExitCode {
|
|||
let mut forge = HttpForge::new(&options.forge_url);
|
||||
let mut journal = |report: &huginn_daemon::sources::Report| println!("{report}");
|
||||
match refresh(&mut embedder, &mut index, &mut forge, &options.state_root, &mut journal) {
|
||||
Ok(refreshed) if refreshed.failed.is_empty() && refreshed.retirement_withheld.is_none() => ExitCode::SUCCESS,
|
||||
Ok(refreshed) if refreshed.is_clean() => ExitCode::SUCCESS,
|
||||
Ok(refreshed) => {
|
||||
if !refreshed.failed.is_empty() {
|
||||
eprintln!("huginn-sources: {} repos failed: {}", refreshed.failed.len(), refreshed.failed.join(", "));
|
||||
|
|
|
|||
|
|
@ -199,6 +199,13 @@ pub struct Refreshed {
|
|||
pub retirement_withheld: Option<String>,
|
||||
}
|
||||
|
||||
impl Refreshed {
|
||||
/// Every repo converged and the catalog could be trusted to retire from.
|
||||
pub fn is_clean(&self) -> bool {
|
||||
self.failed.is_empty() && self.retirement_withheld.is_none()
|
||||
}
|
||||
}
|
||||
|
||||
/// Brings the collection to the forge's current state. A collection that
|
||||
/// exists without Huginn's label is refused untouched. One repo's failure is
|
||||
/// logged and the others go on; the caller exits nonzero if any failed.
|
||||
|
|
|
|||
|
|
@ -380,6 +380,14 @@ fn a_repo_renamed_only_by_case_keeps_no_stale_points() {
|
|||
assert_eq!(rig.index.cursors().into_iter().collect::<Vec<_>>(), [("demo".to_owned(), head)]);
|
||||
}
|
||||
|
||||
/// A run is clean only when no repo failed and retirement was not withheld.
|
||||
#[test]
|
||||
fn a_run_is_clean_only_when_nothing_failed_and_retirement_was_not_withheld() {
|
||||
assert!(Refreshed::default().is_clean());
|
||||
assert!(!Refreshed { failed: vec!["Demo".into()], retirement_withheld: None }.is_clean());
|
||||
assert!(!Refreshed { failed: Vec::new(), retirement_withheld: Some("short".into()) }.is_clean());
|
||||
}
|
||||
|
||||
/// A mirror no cursor knows (a first ingest that never finished) is retired
|
||||
/// with its points too.
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Reference in a new issue