From bde569d0551604b984adb16e9f7de9d22c534c9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E6=AD=A3=E8=B6=85?= Date: Wed, 6 May 2026 08:47:02 +0800 Subject: [PATCH] test(getobject): cover buffer threshold edge cases (#2817) --- rustfs/src/app/object_usecase.rs | 43 ++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/rustfs/src/app/object_usecase.rs b/rustfs/src/app/object_usecase.rs index 4543cd934..1a108ed0a 100644 --- a/rustfs/src/app/object_usecase.rs +++ b/rustfs/src/app/object_usecase.rs @@ -4609,6 +4609,49 @@ mod tests { )); } + #[test] + fn should_buffer_get_object_in_memory_respects_configured_threshold_below_cap() { + let info = ObjectInfo::default(); + let configured_threshold = 10_i64 * 1024 * 1024; + + assert!(should_buffer_get_object_in_memory_with_threshold( + &info, + configured_threshold, + None, + false, + configured_threshold + )); + assert!(!should_buffer_get_object_in_memory_with_threshold( + &info, + configured_threshold + 1, + None, + false, + configured_threshold + )); + } + + #[test] + fn should_buffer_get_object_in_memory_rejects_unknown_lengths_and_disabled_thresholds() { + let info = ObjectInfo::default(); + let configured_threshold = 10_i64 * 1024 * 1024; + + assert!(!should_buffer_get_object_in_memory_with_threshold( + &info, + 0, + None, + false, + configured_threshold + )); + assert!(!should_buffer_get_object_in_memory_with_threshold( + &info, + -1, + None, + false, + configured_threshold + )); + assert!(!should_buffer_get_object_in_memory_with_threshold(&info, 1024, None, false, 0)); + } + struct ReadProbeReader { reads: Arc, }