Expose typed Prepared Lower failures

This commit is contained in:
ms2k 2026-07-19 03:18:50 +09:00
commit 30cd36dcdd
2 changed files with 694 additions and 249 deletions

View file

@ -279,7 +279,10 @@ fn recovery_deletes_only_exact_owned_stage_and_preserves_foreign_stage() {
fixture.catalog.record_prepare(&intent).unwrap();
std::fs::create_dir(fixture.root.join(&stage)).unwrap();
std::fs::write(fixture.root.join(&stage).join("foreign"), b"keep").unwrap();
assert!(fixture.store.recover_prepare(&intent).is_err());
assert!(matches!(
fixture.store.recover_prepare(&intent),
Err(PreparedLowerError::Recovery { .. })
));
assert!(fixture.root.join(&stage).join("foreign").exists());
std::fs::remove_dir_all(fixture.root.join(&stage)).unwrap();
assert_eq!(
@ -337,7 +340,7 @@ fn reclaim_refuses_forged_identity_and_leases() {
fixture.catalog.acquire_lease(&lease).unwrap();
assert!(matches!(
fixture.store.reclaim(&artifact),
Err(error)
Err(error @ PreparedLowerError::Catalog { .. })
if matches!(error.downcast_ref::<CatalogError>(), Some(CatalogError::LeasesPresent))
));
fixture.catalog.release_lease(&lease).unwrap();
@ -367,7 +370,10 @@ fn selected_gc_is_idempotent_only_at_the_durable_reclaim_boundary() {
))
.unwrap();
let id = artifact.prepared_artifact_id;
assert!(fixture.store.gc_artifacts(&[id, id]).is_err());
assert!(matches!(
fixture.store.gc_artifacts(&[id, id]),
Err(PreparedLowerError::Reclaim { .. })
));
let lease = lazaret_core::records::ArtifactLease {
prepared_artifact_id: id,

View file

@ -69,7 +69,10 @@ fn request_manifest_identity_must_match_verified_layout_manifest() {
let mut request = fixture.request(3, &[(bytes, OCI_TAR)]);
request.selected_manifest_digest = [0xff; 32];
assert!(fixture.store.prepare(&request).is_err());
assert!(matches!(
fixture.store.prepare(&request),
Err(PreparedLowerError::ManifestSelection { .. })
));
let snapshot = fixture.catalog.snapshot().unwrap();
assert!(snapshot.prepared_artifacts.is_empty());
assert!(snapshot.prepare_operations.is_empty());
@ -191,7 +194,10 @@ fn unmapped_nonzero_owners_refuse_before_publication() {
}],
};
assert!(fixture.store.prepare(&request).is_err());
assert!(matches!(
fixture.store.prepare(&request),
Err(PreparedLowerError::Materialization { .. })
));
assert!(
fixture
.catalog
@ -258,7 +264,10 @@ fn hostile_and_corrupt_layers_refuse_without_publication() {
for (index, bytes) in cases.into_iter().enumerate() {
let fixture = Fixture::new();
let request = fixture.request(u8::try_from(index).unwrap() + 10, &[(bytes, OCI_TAR)]);
assert!(fixture.store.prepare(&request).is_err());
assert!(matches!(
fixture.store.prepare(&request),
Err(PreparedLowerError::Materialization { .. })
));
let snapshot = fixture.catalog.snapshot().unwrap();
assert!(snapshot.prepared_artifacts.is_empty());
assert!(snapshot.prepare_operations.is_empty());
@ -291,7 +300,10 @@ fn hostile_and_corrupt_layers_refuse_without_publication() {
.find(|path| std::fs::metadata(path).unwrap().len() > 1024)
.unwrap();
OpenOptionsExt::append_byte(&blob);
assert!(fixture.store.prepare(&request).is_err());
assert!(matches!(
fixture.store.prepare(&request),
Err(PreparedLowerError::LayerValidation { .. })
));
assert!(
fixture
.catalog