mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-10-28 07:32:15 +00:00
refactor: Simplify validation parsing using let-chains in sync.rs and wrap unsafe env::set_var in tests
- Replace nested if-let statements with let-chain pattern for VmRSS memory parsing in /proc/self/status - Replace nested if-let statements with let-chain pattern for Redis used_memory parsing - Wrap std::env::set_var calls in unsafe blocks in validation_tests.rs for MAX_BYTES_LIMIT and MAX_AMOUNT_LIMIT
This commit is contained in:
@@ -12,7 +12,7 @@ fn test_validate_bytes_zero() {
|
||||
|
||||
#[test]
|
||||
fn test_validate_bytes_exceeds_limit() {
|
||||
std::env::set_var("MAX_BYTES_LIMIT", "1000000000000");
|
||||
unsafe { std::env::set_var("MAX_BYTES_LIMIT", "1000000000000"); }
|
||||
let result = validate_bytes(2_000_000_000_000); // 2TB
|
||||
assert!(result.is_err());
|
||||
match result.unwrap_err() {
|
||||
@@ -75,7 +75,7 @@ fn test_validate_amount_negative() {
|
||||
|
||||
#[test]
|
||||
fn test_validate_amount_exceeds_limit() {
|
||||
std::env::set_var("MAX_AMOUNT_LIMIT", "10000");
|
||||
unsafe { std::env::set_var("MAX_AMOUNT_LIMIT", "10000"); }
|
||||
let result = validate_amount(20_000.0);
|
||||
assert!(result.is_err());
|
||||
match result.unwrap_err() {
|
||||
|
||||
Reference in New Issue
Block a user