summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/build.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/build.rs b/tests/build.rs
index c6ed70d..dc9443c 100644
--- a/tests/build.rs
+++ b/tests/build.rs
@@ -23,6 +23,14 @@ impl PackageInstaller for FixtureInstaller {
}
}
+struct FailingInstaller;
+
+impl PackageInstaller for FailingInstaller {
+ fn install(&self, _request: &PackageRequest) -> anyhow::Result<()> {
+ anyhow::bail!("simulated package installation failure")
+ }
+}
+
#[derive(Default)]
struct FixtureInitramfsBuilder;
@@ -154,3 +162,22 @@ fn rejects_a_missing_apt_configuration_before_creating_the_workspace() {
assert!(!workspace.exists());
assert!(installer.requests.borrow().is_empty());
}
+
+#[test]
+fn removes_the_new_workspace_when_package_installation_fails() {
+ 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 mut executor = BuildExecutor::new(FailingInstaller, FixtureInitramfsBuilder);
+ let workspace = fixture.path().join("work");
+ let artifact = fixture.path().join("image.tar");
+
+ let error = executor
+ .execute(&plan, &workspace, "profiles/apt.conf", &artifact)
+ .expect_err("failed installation must fail the build");
+
+ assert!(error.to_string().contains("simulated package installation failure"));
+ assert!(!workspace.exists(), "failed build must not leave a workspace");
+ assert!(!artifact.exists());
+}