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

@ -0,0 +1,48 @@
//! Package upgrade job: runs the host updater, streams its output into the job log,
//! then refreshes the inventory.
use std::sync::Arc;
use async_trait::async_trait;
use domain::host::validate_package_name;
use domain::ports::HostUpdater;
use domain::DomainError;
use serde::{Deserialize, Serialize};
use crate::jobs::{JobHandler, JobLog};
use crate::InventoryService;
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub struct UpgradeParams {
/// Empty = upgrade all packages.
#[serde(default)]
pub packages: Vec<String>,
}
impl UpgradeParams {
pub fn validate(&self) -> Result<(), DomainError> {
self.packages
.iter()
.try_for_each(|p| validate_package_name(p))
}
pub fn to_json(&self) -> String {
serde_json::to_string(self).unwrap_or_default()
}
pub fn from_json(s: Option<&str>) -> Result<Self, DomainError> {
let _ = s;
todo!()
}
}
pub struct PackageUpgradeJob {
pub updater: Arc<dyn HostUpdater>,
pub inventory: Arc<InventoryService>,
}
#[async_trait]
impl JobHandler for PackageUpgradeJob {
async fn run(&self, _params: Option<String>, _log: &dyn JobLog) -> Result<(), String> {
todo!()
}
}