diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/initramfs.rs | 29 | ||||
| -rw-r--r-- | tests/package_installer.rs | 28 |
2 files changed, 52 insertions, 5 deletions
diff --git a/tests/initramfs.rs b/tests/initramfs.rs index 5ad0b99..85908b2 100644 --- a/tests/initramfs.rs +++ b/tests/initramfs.rs @@ -67,15 +67,34 @@ fn make_initrd_adapter_uses_typed_chroot_arguments_and_records_output_digest() { let result = builder.build(&request).expect("build initramfs"); + let workdir = rootfs + .path() + .parent() + .expect("rootfs fixture has a parent") + .display() + .to_string(); assert_eq!( builder.runner().invocations, vec![Invocation::new( - "chroot", + "sudo", [ - rootfs.path().as_os_str().to_owned(), - "make-initrd".into(), - "-k".into(), - "6.12-rt1".into(), + "-n", + "-u", + "hermes", + "hsh-run", + "--rooter", + "--mountpoints=/proc", + "--workdir", + &workdir, + "--", + "make-initrd", + "-N", + "-v", + "-k", + "6.12-rt1", + "AUTODETECT=", + "-c", + "/etc/initrd.mk.oem", ], )] ); diff --git a/tests/package_installer.rs b/tests/package_installer.rs index 76d8683..74bf9aa 100644 --- a/tests/package_installer.rs +++ b/tests/package_installer.rs @@ -102,3 +102,31 @@ fn build_plan_compiles_its_typed_package_request() { ); assert_eq!(request.selectors(), ["^kernel-(image|modules-())-(rt)$"]); } + +#[test] +fn sudo_user_runner_executes_hasher_commands_as_the_configured_user() { + let runner = alt_controller_image::hasher::SudoUserRunner::new("hermes"); + let invocation = runner.wrap(Invocation::new("hsh", ["--version"])); + + assert_eq!( + invocation, + Invocation::new("sudo", ["-n", "-u", "hermes", "hsh", "--version"]) + ); + let preparation = runner.prepare_workdir(std::path::Path::new("/build/work")); + assert_eq!( + preparation, + Invocation::new( + "sudo", + [ + "-n", + "install", + "-d", + "-o", + "hermes", + "-g", + "hermes", + "/build/work" + ] + ) + ); +} |