diff options
| author | Hermes Agent <hermes@localhost> | 2026-08-12 05:45:02 +0000 |
|---|---|---|
| committer | Hermes Agent <hermes@localhost> | 2026-08-12 05:45:02 +0000 |
| commit | 7842b48e60cd54be0e5f248563821a766590b0f0 (patch) | |
| tree | 2e49bdd2ca877d094df08c3bf168e11f7ccf264e /tests | |
| parent | b6a122940830d0f438edb24e000ee9447e8419fe (diff) | |
Prevent archive overwrite races
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/archive.rs | 18 |
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"); |