diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/build.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/build.rs b/tests/build.rs index 987811a..cae79b0 100644 --- a/tests/build.rs +++ b/tests/build.rs @@ -31,6 +31,14 @@ impl PackageInstaller for FailingInstaller { } } +struct RootfslessInstaller; + +impl PackageInstaller for RootfslessInstaller { + fn install(&self, _request: &PackageRequest) -> anyhow::Result<()> { + Ok(()) + } +} + struct FailingInitramfsBuilder; impl InitramfsBuilder for FailingInitramfsBuilder { @@ -191,6 +199,25 @@ fn removes_the_new_workspace_when_package_installation_fails() { } #[test] +fn removes_the_new_workspace_when_the_installer_does_not_create_a_rootfs() { + 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(RootfslessInstaller, 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("missing rootfs must fail the build"); + + assert!(error.to_string().contains("package installer did not create rootfs")); + assert!(!workspace.exists(), "failed build must not leave a workspace"); + assert!(!artifact.exists()); +} + +#[test] fn removes_the_new_workspace_when_initramfs_build_fails() { let fixture = tempdir().expect("fixture directory"); let spec = ImageSpec::load(std::path::Path::new("profiles/alt-controller.toml")) |