mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-24 21:26:28 +00:00
test(e2e): enforce external client prerequisites (#6402)
This commit is contained in:
@@ -494,15 +494,20 @@ fn awscurl_binary_path() -> PathBuf {
|
||||
.unwrap_or_else(|| PathBuf::from("awscurl"))
|
||||
}
|
||||
|
||||
pub fn awscurl_available() -> bool {
|
||||
let path = awscurl_binary_path();
|
||||
if path.components().count() > 1 || path.is_absolute() {
|
||||
return path.is_file();
|
||||
fn verify_awscurl_path(path: &Path) -> std::io::Result<()> {
|
||||
let output = Command::new(path).arg("--help").output()?;
|
||||
if output.status.success() {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
std::env::var_os("PATH")
|
||||
.map(|paths| std::env::split_paths(&paths).any(|dir| dir.join(&path).is_file()))
|
||||
.unwrap_or(false)
|
||||
Err(std::io::Error::other(format!(
|
||||
"awscurl prerequisite check failed: {}",
|
||||
String::from_utf8_lossy(&output.stderr).trim()
|
||||
)))
|
||||
}
|
||||
|
||||
pub fn require_awscurl() -> std::io::Result<()> {
|
||||
verify_awscurl_path(&awscurl_binary_path())
|
||||
}
|
||||
|
||||
// Global initialization
|
||||
@@ -1747,6 +1752,22 @@ mod tests {
|
||||
assert_eq!(normalize_rustfs_build_features(" , "), None);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_awscurl_is_a_prerequisite_failure() {
|
||||
let missing = std::env::temp_dir().join(format!("missing-awscurl-{}", Uuid::new_v4()));
|
||||
|
||||
let error = verify_awscurl_path(&missing).expect_err("a missing awscurl binary must fail the test prerequisite");
|
||||
|
||||
assert_eq!(error.kind(), ErrorKind::NotFound);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn available_awscurl_client_passes_prerequisite_check() {
|
||||
let executable = std::env::current_exe().expect("the test executable should have a path");
|
||||
|
||||
verify_awscurl_path(&executable).expect("an available client with a working help command should pass");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn capture_log_path_uses_temp_directory_basename() {
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user