#![allow(clippy::unwrap_used, clippy::expect_used)]
use std::time::Duration;
use vectorizer_sdk::http_transport::parse_retry_after_secs;
#[test]
fn missing_header_returns_default() {
assert_eq!(parse_retry_after_secs(None), Duration::from_secs(1));
}
#[test]
fn empty_or_whitespace_returns_default() {
assert_eq!(parse_retry_after_secs(Some("")), Duration::from_secs(1));
assert_eq!(parse_retry_after_secs(Some(" ")), Duration::from_secs(1));
}
#[test]
fn zero_returns_default_to_avoid_busy_loop() {
assert_eq!(parse_retry_after_secs(Some("0")), Duration::from_secs(1));
}
#[test]
fn unparseable_string_returns_default() {
assert_eq!(
parse_retry_after_secs(Some("not-a-number")),
Duration::from_secs(1),
);
}
#[test]
fn small_values_pass_through_verbatim() {
assert_eq!(parse_retry_after_secs(Some("3")), Duration::from_secs(3));
assert_eq!(parse_retry_after_secs(Some("7")), Duration::from_secs(7));
assert_eq!(parse_retry_after_secs(Some(" 5 ")), Duration::from_secs(5));
}
#[test]
fn large_values_are_capped_at_30s() {
assert_eq!(
parse_retry_after_secs(Some("3600")),
Duration::from_secs(30),
);
assert_eq!(parse_retry_after_secs(Some("31")), Duration::from_secs(30));
}