diff options
| author | Bryan Newbold <bnewbold@archive.org> | 2020-08-25 18:59:34 -0700 | 
|---|---|---|
| committer | Bryan Newbold <bnewbold@archive.org> | 2020-08-25 18:59:34 -0700 | 
| commit | 52c8213c0889f0ff16ff48c83121fb41bad56ba7 (patch) | |
| tree | 14d1ae8d8f9ccc6f019b788bb97d48a949d93e32 /tests/common | |
| parent | 2f9054309e3d12be5b9d9be56c09e935c0bc0c06 (diff) | |
| download | es-public-proxy-52c8213c0889f0ff16ff48c83121fb41bad56ba7.tar.gz es-public-proxy-52c8213c0889f0ff16ff48c83121fb41bad56ba7.zip  | |
fmt
Diffstat (limited to 'tests/common')
| -rw-r--r-- | tests/common/mod.rs | 23 | 
1 files changed, 16 insertions, 7 deletions
diff --git a/tests/common/mod.rs b/tests/common/mod.rs index 811b4b9..2d06d81 100644 --- a/tests/common/mod.rs +++ b/tests/common/mod.rs @@ -1,7 +1,6 @@ - -use hyper::{Request, Body, Method}; -use std::path::Path; +use hyper::{Body, Method, Request};  use std::io::BufRead; +use std::path::Path;  pub struct ExampleParts {      pub method: String, @@ -10,11 +9,19 @@ pub struct ExampleParts {  }  pub fn load_parts(path: &Path) -> ExampleParts { -      let file = std::fs::File::open(path).unwrap();      let mut lines = std::io::BufReader::new(file).lines(); -    let first_line: Vec<String> = lines.next().unwrap().unwrap().split(" ").map(|v| v.into()).collect(); -    let body: Vec<String> = lines.map(|v| v.into()).collect::<Result<Vec<String>, _>>().unwrap(); +    let first_line: Vec<String> = lines +        .next() +        .unwrap() +        .unwrap() +        .split(" ") +        .map(|v| v.into()) +        .collect(); +    let body: Vec<String> = lines +        .map(|v| v.into()) +        .collect::<Result<Vec<String>, _>>() +        .unwrap();      let body: Option<String> = if body.len() <= 1 {          None      } else { @@ -32,7 +39,9 @@ pub fn load_request(path: &Path) -> Request<Body> {      let parts = load_parts(path);      Request::builder()          .uri(parts.path_and_query) -        .method(Method::from_bytes(parts.method.as_bytes()).expect("valid method in example text file")) +        .method( +            Method::from_bytes(parts.method.as_bytes()).expect("valid method in example text file"), +        )          .body(match parts.body {              Some(data) => Body::from(data),              None => Body::empty(),  | 
