diff options
author | Bryan Newbold <bnewbold@archive.org> | 2020-08-18 00:06:02 -0700 |
---|---|---|
committer | Bryan Newbold <bnewbold@archive.org> | 2020-08-18 00:06:02 -0700 |
commit | 38d3f8143a26c448f9f4898962ceca3d3e877163 (patch) | |
tree | 2563070458c9f21f5c074615b554366eaa5f1c3e /tests/common/mod.rs | |
parent | d1d925e55e8a75e72813a647fa2fe843023f8980 (diff) | |
download | es-public-proxy-38d3f8143a26c448f9f4898962ceca3d3e877163.tar.gz es-public-proxy-38d3f8143a26c448f9f4898962ceca3d3e877163.zip |
start of test infra
Diffstat (limited to 'tests/common/mod.rs')
-rw-r--r-- | tests/common/mod.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/common/mod.rs b/tests/common/mod.rs new file mode 100644 index 0000000..f0b9bea --- /dev/null +++ b/tests/common/mod.rs @@ -0,0 +1,24 @@ + +use std::io::BufRead; + +pub struct ExampleRequest { + pub method: String, + pub path_and_query: String, + pub body: Option<String>, +} + +pub fn load_request(name: &str) -> ExampleRequest { + + let path = format!("tests/files/{}.txt", name); + 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 body: String = body.join("\n"); + + ExampleRequest { + method: first_line[0].clone(), + path_and_query: first_line[1].clone(), + body: Some(body), + } +} |