Skip to content

Commit

Permalink
feat(client): add test for keep alive parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
joelwurtz committed Feb 25, 2025
1 parent 8b30657 commit 073b3ad
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions client/src/service/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,3 +239,23 @@ fn parse_keep_alive<B>(res: &crate::http::Response<B>) -> (Option<Duration>, Opt

(timeout, max)
}

#[cfg(test)]
mod test {
use crate::{body::ResponseBody, http};

use super::*;

#[tokio::test]
async fn test_parse_timeout_and_max() {
let res = http::Response::builder()
.header("keep-alive", "timeout=100, max=10")
.body(ResponseBody::Eof)
.unwrap();

let (timeout, max) = parse_keep_alive(&res);

assert_eq!(timeout, Some(Duration::from_secs(100)));
assert_eq!(max, Some(10));
}
}

0 comments on commit 073b3ad

Please sign in to comment.