WP-11: contract and failing tests for package upgrades
Some checks failed
CI / backend (push) Has been cancelled
CI / frontend (push) Has been cancelled
CI / ui (push) Has been cancelled

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
Dennis Nemec
2026-09-02 22:24:40 +02:00
parent b6ddb8889d
commit 1f56f015a2
18 changed files with 524 additions and 2 deletions

View File

@ -368,3 +368,34 @@ impl InventoryRepository for MemInventory {
Ok(self.0.lock().unwrap().clone())
}
}
use domain::ports::{HostUpdater, LineSink};
/// Records the requested packages and emits a few lines.
#[derive(Default)]
pub struct FakeUpdater {
pub calls: Mutex<Vec<Vec<String>>>,
pub fail: bool,
}
#[async_trait]
impl HostUpdater for FakeUpdater {
async fn upgrade(&self, packages: &[String], out: &dyn LineSink) -> Result<(), DomainError> {
self.calls.lock().unwrap().push(packages.to_vec());
out.line("Reading package lists...");
out.line(&format!(
"Upgrading {} package(s)",
if packages.is_empty() {
"all".to_string()
} else {
packages.len().to_string()
}
));
if self.fail {
return Err(DomainError::Unavailable(
"apt-get exited with status 100".into(),
));
}
Ok(())
}
}