summaryrefslogtreecommitdiff
path: root/tests/archive.rs
diff options
context:
space:
mode:
authorHermes Agent <hermes@localhost>2026-08-12 05:03:36 +0000
committerHermes Agent <hermes@localhost>2026-08-12 05:03:36 +0000
commit251509d734a635f8e6448cef0925d881d4f5f184 (patch)
tree899e28b8ec86e39981486f1d208642e955630636 /tests/archive.rs
parent4c01f2c2464f4133cb48125c8f2c55827cf0bf67 (diff)
Publish archives atomically
Diffstat (limited to 'tests/archive.rs')
-rw-r--r--tests/archive.rs17
1 files changed, 17 insertions, 0 deletions
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");
+}