Skip to content

Commit cc4c7a4

Browse files
committed
feat(client): add test for keep alive parsing
1 parent 8b30657 commit cc4c7a4

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

client/src/service/http.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,3 +239,23 @@ fn parse_keep_alive<B>(res: &crate::http::Response<B>) -> (Option<Duration>, Opt
239239

240240
(timeout, max)
241241
}
242+
243+
#[cfg(test)]
244+
mod test {
245+
use crate::{body::ResponseBody, http};
246+
247+
use super::*;
248+
249+
#[test]
250+
fn test_parse_timeout_and_max() {
251+
let res = http::Response::builder()
252+
.header("keep-alive", "timeout=100, max=10")
253+
.body(ResponseBody::Eof)
254+
.unwrap();
255+
256+
let (timeout, max) = parse_keep_alive(&res);
257+
258+
assert_eq!(timeout, Some(Duration::from_secs(100)));
259+
assert_eq!(max, Some(10));
260+
}
261+
}

0 commit comments

Comments
 (0)