Browse Source

Add TTL normalization tests for Go parity verification

Test that fit_ttl_count normalizes 120m→2h, 24h→1d, 7d→1w even
when count fits in a byte, matching Go's fitTtlCount behavior.
rust-volume-server
Chris Lu 3 days ago
parent
commit
c51293b4e0
  1. 34
      seaweed-volume/src/storage/needle/ttl.rs

34
seaweed-volume/src/storage/needle/ttl.rs

@ -272,4 +272,38 @@ mod tests {
}
);
}
#[test]
fn test_ttl_normalization_under_256() {
// 120 minutes should normalize to 2 hours (matches Go fitTtlCount behavior).
// Even though count=120 fits in a byte, Go always normalizes to the coarsest unit.
let ttl = TTL::read("120m").unwrap();
assert_eq!(
ttl,
TTL {
count: 2,
unit: TTL_UNIT_HOUR
}
);
// 24 hours should normalize to 1 day
let ttl = TTL::read("24h").unwrap();
assert_eq!(
ttl,
TTL {
count: 1,
unit: TTL_UNIT_DAY
}
);
// 7 days should normalize to 1 week
let ttl = TTL::read("7d").unwrap();
assert_eq!(
ttl,
TTL {
count: 1,
unit: TTL_UNIT_WEEK
}
);
}
}
Loading…
Cancel
Save