From 251509d734a635f8e6448cef0925d881d4f5f184 Mon Sep 17 00:00:00 2001 From: Hermes Agent Date: Wed, 12 Aug 2026 05:03:36 +0000 Subject: Publish archives atomically --- tests/archive.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests/archive.rs') diff --git a/tests/archive.rs b/tests/archive.rs index e31b65a..da3e66a 100644 --- a/tests/archive.rs +++ b/tests/archive.rs @@ -1,5 +1,6 @@ use std::fs; use std::os::unix::fs::symlink; +use std::os::unix::net::UnixListener; use alt_controller_image::archive::NativeTarWriter; use tar::Archive; @@ -105,3 +106,19 @@ fn rejects_a_missing_rootfs() { .expect_err("missing rootfs must fail"); assert!(error.to_string().contains("rootfs is not a directory")); } + +#[test] +fn removes_partial_output_when_an_unsupported_entry_stops_packaging() { + let fixture = tempdir().expect("fixture directory"); + let rootfs = fixture.path().join("rootfs"); + fs::create_dir(&rootfs).expect("create rootfs"); + let _socket = UnixListener::bind(rootfs.join("image-builder.sock")).expect("create socket"); + let artifact = fixture.path().join("image.tar"); + + let error = NativeTarWriter::new() + .write(&rootfs, &artifact) + .expect_err("socket entries must be rejected"); + + assert!(error.to_string().contains("unsupported rootfs entry type")); + assert!(!artifact.exists(), "failed packaging must not publish a partial archive"); +} -- cgit v1.2.3