test(install): verify the explicit Portage plan end to end

Add an executor test: resolve an explicit --portage plan, confirm verification
fails before the merge and succeeds once the VDB entry exists, so success is
never claimed from a zero exit alone.
This commit is contained in:
Phoebus 2026-09-23 20:32:24 -07:00
parent 4934b4c221
commit b4729e443d

View file

@ -1099,4 +1099,33 @@ mod tests {
let err = resolve_explicit(&exec, root.path(), &request).unwrap_err(); let err = resolve_explicit(&exec, root.path(), &request).unwrap_err();
assert!(err.to_string().contains("already installed"), "{err}"); assert!(err.to_string().contains("already installed"), "{err}");
} }
#[test]
fn an_explicit_portage_install_verifies_against_the_package_database() {
let runner = RecordingRunner::new();
runner.set_response(
"emerge",
ok("Calculating dependencies... done!\n[ebuild N ] app-misc/hello-2.12.1\n"),
);
let exec = make_exec(runner);
let mut request = InstallRequest::new("app-misc/hello");
request.backend = Some(Backend::PortageSource);
// Host-root path so the canned emerge response is reached directly.
let resolved = resolve_explicit(&exec, Path::new("/"), &request).unwrap();
assert!(matches!(
resolved.action,
SystemAction::InstallPackage { .. }
));
// Verification reads the *target* package database. Before the merge it
// must fail, never claiming success because a command exited zero.
let target = tempfile::tempdir().unwrap();
assert!(verify_installed(&exec, target.path(), &resolved).is_err());
// After the merge the package appears in the VDB.
let vdb = target.path().join("var/db/pkg/app-misc/hello-2.12.1");
std::fs::create_dir_all(&vdb).unwrap();
let text = verify_installed(&exec, target.path(), &resolved).unwrap();
assert!(text.contains("Portage package database"), "{text}");
}
} }