Skip to content

Commit 1173577

Browse files
feloyclaude
andcommitted
test(build): use improbable name to test missing-binary detection
Avoids creating a temp directory and mutating PATH. The name a_really_improbable_name is virtually guaranteed to be absent. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Philippe Martin <phmartin@redhat.com>
1 parent 2820d17 commit 1173577

2 files changed

Lines changed: 4 additions & 9 deletions

File tree

crates/container-image-builder/src/lib.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -393,15 +393,7 @@ mod tests {
393393

394394
#[test]
395395
fn check_in_path_fails_for_missing_binary() {
396-
let dir = tempfile::tempdir().unwrap();
397-
let original_path = std::env::var_os("PATH").unwrap_or_default();
398-
399-
// Use a path that contains no "podman" binary.
400-
std::env::set_var("PATH", dir.path());
401-
let result = ContainerCli::Podman.check_in_path();
402-
403-
std::env::set_var("PATH", original_path);
404-
assert!(result.is_err());
396+
assert!(which("a_really_improbable_name").is_err());
405397
}
406398

407399
// --- RuntimeNotFoundError ---

tests/integration_test.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,7 @@ fn build_image_with_workspace(tag: &str, workspace_json: &str, extra_args: &[&st
798798
let binary = env!("CARGO_BIN_EXE_openshell-image-builder");
799799
let status = Command::new(binary)
800800
.current_dir(dir.path())
801+
.args(["--runtime", "podman"])
801802
.arg("--with-workspace-config")
802803
.args(extra_args)
803804
.arg(tag)
@@ -984,6 +985,7 @@ fn build_image_with_local_feature(tag: &str, extra_args: &[&str]) -> String {
984985
let binary = env!("CARGO_BIN_EXE_openshell-image-builder");
985986
let status = Command::new(binary)
986987
.current_dir(dir.path())
988+
.args(["--runtime", "podman"])
987989
.arg("--with-workspace-config")
988990
.args(extra_args)
989991
.arg(tag)
@@ -1043,6 +1045,7 @@ fn build_image_with_skills(tag: &str, extra_args: &[&str]) -> String {
10431045
let binary = env!("CARGO_BIN_EXE_openshell-image-builder");
10441046
let status = Command::new(binary)
10451047
.current_dir(dir.path())
1048+
.args(["--runtime", "podman"])
10461049
.arg("--with-workspace-config")
10471050
.args(extra_args)
10481051
.arg(tag)

0 commit comments

Comments
 (0)