mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-26 16:28:15 +00:00
refactor(storage): drop ecfs test-only helper (#2484)
This commit is contained in:
@@ -3088,6 +3088,33 @@ mod tests {
|
||||
assert_eq!(err.code(), &S3ErrorCode::InvalidStorageClass);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn normalize_delete_objects_version_id_handles_null_uuid_and_empty_values() {
|
||||
let (raw, uuid) = normalize_delete_objects_version_id(Some("null".to_string())).unwrap();
|
||||
assert_eq!(raw.as_deref(), Some("null"));
|
||||
assert_eq!(uuid, Some(Uuid::nil()));
|
||||
|
||||
let (raw, uuid) = normalize_delete_objects_version_id(Some(String::new())).unwrap();
|
||||
assert!(raw.is_none());
|
||||
assert!(uuid.is_none());
|
||||
|
||||
let (raw, uuid) = normalize_delete_objects_version_id(Some(" ".to_string())).unwrap();
|
||||
assert!(raw.is_none());
|
||||
assert!(uuid.is_none());
|
||||
|
||||
let valid = "550e8400-e29b-41d4-a716-446655440000".to_string();
|
||||
let (raw, uuid) = normalize_delete_objects_version_id(Some(valid.clone())).unwrap();
|
||||
assert_eq!(raw.as_deref(), Some(valid.as_str()));
|
||||
assert_eq!(uuid, Some(Uuid::parse_str(&valid).unwrap()));
|
||||
|
||||
let err = normalize_delete_objects_version_id(Some("not-a-uuid".to_string())).unwrap_err();
|
||||
assert!(!err.is_empty());
|
||||
|
||||
let (raw, uuid) = normalize_delete_objects_version_id(None).unwrap();
|
||||
assert!(raw.is_none());
|
||||
assert!(uuid.is_none());
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn execute_put_object_tagging_rejects_too_many_tags() {
|
||||
let tag_set = (0..11)
|
||||
|
||||
@@ -103,25 +103,6 @@ impl FS {
|
||||
}
|
||||
Ok(out)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn normalize_delete_objects_version_id(
|
||||
&self,
|
||||
version_id: Option<String>,
|
||||
) -> std::result::Result<(Option<String>, Option<Uuid>), String> {
|
||||
let version_id = version_id.map(|v| v.trim().to_string()).filter(|v| !v.is_empty());
|
||||
match version_id {
|
||||
Some(id) => {
|
||||
if id.eq_ignore_ascii_case("null") {
|
||||
Ok((Some("null".to_string()), Some(Uuid::nil())))
|
||||
} else {
|
||||
let uuid = Uuid::parse_str(&id).map_err(|e| e.to_string())?;
|
||||
Ok((Some(id), Some(uuid)))
|
||||
}
|
||||
}
|
||||
None => Ok((None, None)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn parse_object_version_id(version_id: Option<String>) -> S3Result<Option<Uuid>> {
|
||||
|
||||
@@ -856,31 +856,6 @@ mod tests {
|
||||
assert_eq!(formatted, "550e8400-e29b-41d4-a716-446655440000");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_delete_objects_version_id_normalization() {
|
||||
use uuid::Uuid;
|
||||
|
||||
let fs = FS::new();
|
||||
|
||||
let (raw, uuid) = fs.normalize_delete_objects_version_id(Some("null".to_string())).unwrap();
|
||||
assert_eq!(raw.as_deref(), Some("null"));
|
||||
assert_eq!(uuid, Some(Uuid::nil()));
|
||||
|
||||
let valid = "550e8400-e29b-41d4-a716-446655440000".to_string();
|
||||
let (raw, uuid) = fs.normalize_delete_objects_version_id(Some(valid.clone())).unwrap();
|
||||
assert_eq!(raw.as_deref(), Some(valid.as_str()));
|
||||
assert_eq!(uuid, Some(Uuid::parse_str(&valid).unwrap()));
|
||||
|
||||
let err = fs
|
||||
.normalize_delete_objects_version_id(Some("not-a-uuid".to_string()))
|
||||
.unwrap_err();
|
||||
assert!(!err.is_empty());
|
||||
|
||||
let (raw, uuid) = fs.normalize_delete_objects_version_id(None).unwrap();
|
||||
assert!(raw.is_none());
|
||||
assert!(uuid.is_none());
|
||||
}
|
||||
|
||||
/// Test that ListObjectVersionsOutput markers are correctly set
|
||||
/// This verifies the fix for boto3 ParamValidationError
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user