refactor: extract embedded startup control helpers (#3661)

This commit is contained in:
安正超
2026-06-20 21:57:03 +08:00
committed by GitHub
parent 84e292c6da
commit 0cf7e5cf03
6 changed files with 180 additions and 43 deletions
@@ -3322,6 +3322,7 @@ mod tests {
// SAFETY: this helper is only used from `#[serial]` tests and those tests run under a
// single-thread runtime (`worker_threads = 1`), so no concurrent reader/writer can access
// process environment while `env::set_var`/`env::remove_var` is active.
// SAFETY: keep this note adjacent to the allowance for the repository guard.
#[allow(unsafe_code)]
async fn with_transition_queue_env_async<F, Fut>(capacity: Option<&str>, timeout_ms: Option<&str>, test_fn: F)
where
+10
View File
@@ -32,6 +32,9 @@ lazy_static::lazy_static! {
pub fn check_bucket_name_common(bucket_name: &str, strict: bool) -> Result<()> {
let bucket_name_trimmed = bucket_name.trim();
if strict && bucket_name_trimmed != bucket_name {
return Err(Error::other("Bucket name cannot contain leading or trailing whitespace"));
}
if bucket_name_trimmed.is_empty() {
return Err(Error::other("Bucket name cannot be empty"));
}
@@ -452,6 +455,13 @@ mod tests {
assert!(check_bucket_and_object_names("valid-bucket", "").is_err());
}
#[test]
fn test_strict_bucket_name_rejects_surrounding_whitespace() {
assert!(check_valid_bucket_name_strict(" valid-bucket").is_err());
assert!(check_valid_bucket_name_strict("valid-bucket ").is_err());
assert!(check_valid_bucket_name_strict("\u{c}valid-bucket\u{c}").is_err());
}
#[test]
fn test_check_list_objs_args() {
assert!(check_list_objs_args("valid-bucket", "", &None).is_ok());