use super::*;
#[test]
fn humanize_bytes_formats_units() {
assert_eq!(humanize_bytes(0), "0 B");
assert_eq!(humanize_bytes(512), "512 B");
assert_eq!(humanize_bytes(1024), "1.0 KB");
assert_eq!(humanize_bytes(12_400_000), "11.8 MB");
assert_eq!(humanize_bytes(u64::MAX), "16777216.0 TB");
}
#[test]
fn parses_freed_bytes_from_cleanup_body() {
assert_eq!(
parse_freed_bytes("{\"removed\":1,\"freed_bytes\":4096}"),
Some(4096)
);
}
#[test]
fn freed_bytes_missing_degrades_to_none_for_older_server_bodies() {
assert_eq!(parse_freed_bytes("{\"removed\":1}"), None);
assert_eq!(parse_freed_bytes(""), None);
assert_eq!(parse_freed_bytes("not json"), None);
}