diff options
| author | Hermes Agent <hermes@localhost> | 2026-08-12 05:36:28 +0000 |
|---|---|---|
| committer | Hermes Agent <hermes@localhost> | 2026-08-12 05:36:28 +0000 |
| commit | b6a122940830d0f438edb24e000ee9447e8419fe (patch) | |
| tree | 1925a611290c905a30b5250711130b7640506058 | |
| parent | ca3bb8ede742911a26256b70e5f135d9668c44fb (diff) | |
Test pre-existing artifact build guard
| -rw-r--r-- | tests/build.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/build.rs b/tests/build.rs index d278bce..6613cc7 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -91,6 +91,28 @@ fn refuses_to_reuse_an_existing_workspace() { } #[test] +fn rejects_an_existing_artifact_before_creating_the_workspace_or_installing() { + let fixture = tempdir().expect("fixture directory"); + let spec = ImageSpec::load(std::path::Path::new("profiles/alt-controller.toml")) + .expect("load controller spec"); + let plan = BuildPlan::compile(spec).expect("compile build plan"); + let installer = FixtureInstaller::default(); + let mut executor = BuildExecutor::new(&installer, FixtureInitramfsBuilder); + let workspace = fixture.path().join("work"); + let artifact = fixture.path().join("existing.tar"); + fs::write(&artifact, "do not replace").expect("write pre-existing artifact"); + + let error = executor + .execute(&plan, &workspace, "profiles/apt.conf", &artifact) + .expect_err("pre-existing artifact must be rejected"); + + assert!(error.to_string().contains("output artifact already exists")); + assert_eq!(fs::read_to_string(&artifact).expect("read artifact"), "do not replace"); + assert!(!workspace.exists()); + assert!(installer.requests.borrow().is_empty()); +} + +#[test] fn rejects_a_missing_apt_configuration_before_creating_the_workspace() { let fixture = tempdir().expect("fixture directory"); let spec = ImageSpec::load(std::path::Path::new("profiles/alt-controller.toml")) |