summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/archive.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/archive.rs b/tests/archive.rs
index 6f803ef..6e59837 100644
--- a/tests/archive.rs
+++ b/tests/archive.rs
@@ -125,6 +125,24 @@ fn rejects_an_archive_output_inside_the_rootfs() {
}
#[test]
+fn refuses_to_replace_an_existing_archive() {
+ let fixture = tempdir().expect("fixture directory");
+ let rootfs = fixture.path().join("rootfs");
+ fs::create_dir(&rootfs).expect("create rootfs");
+ fs::write(rootfs.join("controller.conf"), "controller=true\n").expect("write rootfs file");
+ let artifact = fixture.path().join("controller.tar");
+ fs::write(&artifact, "existing artifact").expect("write existing artifact");
+
+ let error = NativeTarWriter::new()
+ .write(&rootfs, &artifact)
+ .expect_err("an existing archive must not be replaced");
+
+ assert!(error.to_string().contains("archive output already exists"));
+ assert_eq!(fs::read_to_string(&artifact).expect("read existing artifact"), "existing artifact");
+ assert!(!fixture.path().join("controller.tar.partial").exists());
+}
+
+#[test]
fn removes_partial_output_when_an_unsupported_entry_stops_packaging() {
let fixture = tempdir().expect("fixture directory");
let rootfs = fixture.path().join("rootfs");